/** * Executes the query, applying the source, the constraint of documents being of the phpcr:class of * this kind of document and builds an array of retrieved documents. * * @param array $params doesn't have any effect * @param mixed $hydrationMode doesn't have any effect * * @return array of documents * * @throws \Exception if $this->sortOrder is not ASC or DESC */ public function execute(array $params = array(), $hydrationMode = null) { if ($this->getSortBy()) { switch ($this->sortOrder) { case 'DESC': $this->qb->orderBy()->desc()->field($this->alias . '.' . $this->sortBy); break; case 'ASC': $this->qb->orderBy()->asc()->field($this->alias . '.' . $this->sortBy); break; default: throw new \Exception('Unsupported sort order direction: ' . $this->sortOrder); } } if ($this->root) { $this->qb->andWhere()->descendant($this->root, $this->alias); } return $this->qb->getQuery()->execute(); }
/** * Evaluate the query and clean the result. * * @param QueryBuilder $qb * * @return array list of result documents */ private function getResult(QueryBuilder $qb) { return array_values($qb->getQuery()->execute()->toArray()); }