QueryObject inheritors are great when you're printing a data to the user,
they may be used in service layer but that's not really suggested.
Don't be afraid to use them in presenters
$this->template->articles = $this->articlesRepository->fetch(new ArticlesQuery());
or in more complex ways
$productsQuery = new ProductsQuery();
$productsQuery
->setColor('green')
->setMaxDeliveryPrice(100)
->setMaxDeliveryMinutes(75);
$productsQuery->size = 'big';
$this->template->products = $this->productsRepository->fetch($productsQuery);
public function filterQueryObject(Kdyby\Doctrine\QueryObject $queryObject) { /** @var Model\CMS\Query\UserQuery $queryObject */ if ($this->search !== NULL) { return $queryObject->search($this->search); } return $queryObject; }
/** * @return \Kdyby\Doctrine\ResultSet */ private function getResultSet() { if (!$this->resultSet) { $this->resultSet = $this->query->fetch($this->repository, $this->hydrationMode); } return $this->resultSet; }
/** * @param int $hydrationMode * @throws QueryException * @return \ArrayIterator */ public function getIterator($hydrationMode = ORM\AbstractQuery::HYDRATE_OBJECT) { if ($this->iterator !== NULL) { return $this->iterator; } $this->query->setHydrationMode($hydrationMode); try { $this->frozen = TRUE; if ($this->fetchJoinCollection && ($this->query->getMaxResults() > 0 || $this->query->getFirstResult() > 0)) { $this->iterator = $this->createPaginatedQuery($this->query)->getIterator(); } else { $this->iterator = new \ArrayIterator($this->query->getResult(NULL)); } if ($this->queryObject !== NULL && $this->repository !== NULL) { $this->queryObject->postFetch($this->repository, $this->iterator); } return $this->iterator; } catch (ORMException $e) { throw new QueryException($e, $this->query, $e->getMessage()); } }
public function filterQueryObject(Kdyby\Doctrine\QueryObject $queryObject) { /** @var Model\CMS\Query\UserQuery $queryObject */ return $queryObject->inRole($this->getSelectedRole()); }
public function filterQueryObject(Kdyby\Doctrine\QueryObject $queryObject) { if ($queryObject instanceof Zax\Model\Doctrine\QueryObject) { return $queryObject->orderBy($this->getSort(), (bool) $this->asc ? 'ASC' : 'DESC'); } }
/** * @param int $id */ public function __construct($id) { parent::__construct(); $this->id = $id; }