Пример #1
0
 /**
  * @param QueryBuilder $queryBuilder
  * @param array        $criteria
  */
 protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = array())
 {
     $metadata = $this->getClassMetadata();
     foreach ($criteria as $property => $value) {
         if (!empty($value)) {
             if ($property === $metadata->nodename) {
                 $queryBuilder->andWhere()->eq()->localName($this->getAlias())->literal($value);
             } else {
                 $queryBuilder->andWhere()->eq()->field($this->getPropertyName($property))->literal($value);
             }
         }
     }
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function restrict($expression, $condition = DataSourceInterface::CONDITION_AND)
 {
     switch ($condition) {
         case DataSourceInterface::CONDITION_AND:
             $parentNode = $this->queryBuilder->andWhere();
             break;
         case DataSourceInterface::CONDITION_OR:
             $parentNode = $this->queryBuilder->orWhere();
             break;
         default:
             throw new \RuntimeException(sprintf('Unknown restrict condition "%s"', $condition));
     }
     $visitor = new ExpressionVisitor($this->queryBuilder);
     $visitor->dispatch($expression, $parentNode);
 }
Пример #3
0
 /**
  * @param QueryBuilder $queryBuilder
  * @param array        $criteria
  */
 protected function applyCriteria(QueryBuilder $queryBuilder, array $criteria = array())
 {
     foreach ($criteria as $property => $value) {
         if (!empty($value)) {
             $queryBuilder->andWhere()->eq()->field($this->getPropertyName($property))->literal($value);
         }
     }
 }
Пример #4
0
 /**
  * {@inheritDoc}
  *
  * @param QueryBuilder $queryBuilder
  */
 public function restrictQuery($queryBuilder)
 {
     $prefixes = $this->getPrefixes();
     if (in_array('', $prefixes) || !count($prefixes)) {
         return;
     }
     $where = $queryBuilder->andWhere()->orX();
     foreach ($prefixes as $prefix) {
         $where->descendant($prefix, $queryBuilder->getPrimaryAlias());
     }
 }
 /**
  * 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();
 }