/** * Executes the query and returns the result based on the hydration mode. * * @param array $parameters Parameters, alternative to calling setParameters. * @param int $hydrationMode Processing mode to be used during the hydration * process. One of the Query::HYDRATE_* constants. * * @return mixed A Collection for HYDRATE_DOCUMENT, \PHPCR\Query\QueryResultInterface for HYDRATE_PHPCR * * @throws QueryException If $hydrationMode is not known. */ public function execute($parameters = null, $hydrationMode = null) { if (!empty($parameters)) { $this->setParameters($parameters); } if (null !== $hydrationMode) { $this->setHydrationMode($hydrationMode); } if (null !== $this->maxResults) { $this->query->setLimit($this->maxResults); } if (null !== $this->firstResult) { $this->query->setOffset($this->firstResult); } foreach ($this->parameters as $key => $value) { $this->query->bindValue($key, $value); } switch ($this->hydrationMode) { case self::HYDRATE_PHPCR: $data = $this->query->execute(); break; case self::HYDRATE_DOCUMENT: $data = $this->dm->getDocumentsByPhpcrQuery($this->query, $this->documentClass, $this->primaryAlias); break; default: throw QueryException::hydrationModeNotKnown($this->hydrationMode); } if (is_array($data)) { $data = new ArrayCollection($data); } return $data; }
/** * {@inheritDoc} */ public function getDocumentsByPhpcrQuery(QueryInterface $query, $className = null, $primarySelector = null) { return $this->wrapped->getDocumentsByPhpcrQuery($query, $className, $primarySelector); }