*/ class WorkflowMapper extends QBMapper { public function __construct(IDBConnection $db) { parent::__construct($db, 'wfda_workflows', Workflow::class); } /** * @throws DoesNotExistException * @throws MultipleObjectsReturnedException */ public function findForUser(int $id, string $userId): Workflow { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->where($qb->expr()->eq('id', $qb->createNamedParameter($id, IQueryBuilder::PARAM_INT))) ->andWhere($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); return $this->findEntity($qb); } /** * @return Workflow[] */ public function findAllForUser(string $userId): array { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))) ->orderBy('id', 'ASC'); return $this->findEntities($qb); } /** * @return Workflow[] */ public function findAllEnabled(): array { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from($this->getTableName()) ->where($qb->expr()->eq('enabled', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL))) ->orderBy('user_id', 'ASC') ->addOrderBy('id', 'ASC'); return $this->findEntities($qb); } }