Check if visitor is applicable to current criterion.

@param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion

@return bool
9987
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\Subtree &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
435836
public function countByCriteria(Criteria $criteria)
    {
        $qb = $this->createCriteriaQueryBuilder($criteria, 'm');

        $qb->select('COUNT(m.id)');

        return $qb->getQuery()->getSingleScalarResult();
    }
324161
public function apply($builder, CriterionInterface $where): ?iterable
    {
        $expression = new Expression($builder, $where->getOperator(), $where->getValue());
        yield from $result = $expression->create($where->getField());

        if ($where->isAnd()) {
            $builder->andWhere($result->getReturn());
        } else {
            $builder->orWhere($result->getReturn());
        }
    }
637009
protected function isCriterionValid(Criterion $criterion): bool
    {
        $isMultipleOperator = (is_array($criterion->value) || $criterion->value instanceof Collection) &&
            in_array($criterion->operator, $this->multipleOperators);
        $isSingleOperator = is_string($criterion->value) && in_array(strtolower($criterion->operator), $this->singleOperators);

        return is_string($criterion->attribute) &&
            is_string($criterion->boolean) &&
            ($isMultipleOperator || $isSingleOperator);
    }
1229587
protected function parseCriterion(array $criterionData): Criterion
    {
        return new Criterion([
            Criterion::ATTRIBUTE => $criterionData[0] ?? null,
            Criterion::OPERATOR => $criterionData[1] ?? null,
            Criterion::VALUE => $criterionData[2] ?? null,
            Criterion::BOOLEAN => $criterionData[3] ?? 'and',
        ]);
    }
843503
def search(self, *criterion, **kwargs):
        
        query = self._query(*criterion)
        query = self._order_by(query, **kwargs)
        query = self._filter(query, **kwargs)
        # NB: pagination must go last
        query = self._paginate(query, **kwargs)
        return query.all()
477760
public function getCriteriaType($criteria) {
        $type = gettype($criteria);
        if ($type === 'object') {
            $type = get_class($criteria);
            if (!$criteria instanceof Om\xPDOCriteria) {
                $this->log(xPDO::LOG_LEVEL_WARN, "Invalid criteria object of class {$type} encountered.", '', __METHOD__, __FILE__, __LINE__);
                $type = null;
            } elseif ($criteria instanceof Om\xPDOQuery) {
                $type = 'xPDOQuery';
            } else {
                $type = 'xPDOCriteria';
            }
        }
        return $type;
    }
619823
public function search($criteria)
    {
        $this->loadModel('Content.Contents');

        try {
            $contents = $this->Contents->search($criteria);
            if ($contents->clause('limit')) {
                $this->paginate['limit'] = $contents->clause('limit');
            }

            // TO-DO: ask search-engine for operator presence
            if (strpos($criteria, 'language:') === false) {
                $contents = $contents->where([
                    'Contents.status >' => 0,
                    'Contents.language IN' => ['', null, I18n::locale()] // any or concrete
                ]);
            }

            $contents = $this->paginate($contents);
        } catch (\Exception $e) {
            $contents = new Collection([]);
        }

        $this->set(compact('contents', 'criteria'));
        $this->viewMode('search-result');
    }
1357841
protected function applyCriteria(Builder $builder, array $criteria)
    {
        foreach ($criteria as $criterion) {
            $criterion->apply($builder);
        }
    }
388448
protected function compileCriterion(Criterion $criterion, array &$bindings): string
    {
        if ($criterion instanceof ValueCriterion) {
            $sql = sprintf(
                '%s %s %s',
                $this->compileIdentifier($criterion->column, $bindings),
                $criterion->rule,
                $this->compileValue($criterion->value, $bindings)
            );

            if ($criterion->rule === 'LIKE' && is_string($criterion->value)) {
                $sql .= ' ESCAPE ?';
                $this->mergeBindings($bindings, ['\\']);
            }

            return $sql;
        }

        if ($criterion instanceof ColumnsCriterion) {
            return sprintf(
                '%s %s %s',
                $this->compileIdentifier($criterion->column1, $bindings),
                $criterion->rule,
                $this->compileIdentifier($criterion->column2, $bindings)
            );
        }

        if ($criterion instanceof BetweenCriterion) {
            return sprintf(
                '(%s %sBETWEEN %s AND %s)',
                $this->compileIdentifier($criterion->column, $bindings),
                $criterion->not ? 'NOT ' : '',
                $this->compileValue($criterion->min, $bindings),
                $this->compileValue($criterion->max, $bindings)
            );
        }

        if ($criterion instanceof CriteriaCriterion) {
            $groupBindings = [];
            $groupSQL = $this->compileCriteria($criterion->criteria, $groupBindings);

            if ($groupSQL === '') {
                return '';
            } else {
                $this->mergeBindings($bindings, $groupBindings);

                return sprintf(
                    '%s(%s)',
                    $criterion->not ? 'NOT ' : '',
                    $groupSQL
                );
            }
        }

        if ($criterion instanceof ExistsCriterion) {
            return sprintf(
                '%sEXISTS %s',
                $criterion->not ? 'NOT ' : '',
                $this->compileSubQuery($criterion->subQuery, $bindings)
            );
        }

        if ($criterion instanceof InCriterion) {
            if (is_array($criterion->values)) {
                if (empty($criterion->values)) {
                    return $this->compileEmptyInCriterion($criterion, $bindings);
                }

                $subQuery = '';
                foreach ($criterion->values as $value) {
                    $subQuery .= ($subQuery ? ', ' : '(') . $this->compileValue($value, $bindings);
                }
                $subQuery .= ')';
            } else {
                $subQuery = $this->compileSubQuery($criterion->values, $bindings);
            }

            return sprintf(
                '%s %sIN %s',
                $this->compileIdentifier($criterion->column, $bindings),
                $criterion->not ? 'NOT ' : '',
                $subQuery
            );
        }

        if ($criterion instanceof NullCriterion) {
            return sprintf(
                '%s IS %sNULL',
                $this->compileIdentifier($criterion->column, $bindings),
                $criterion->isNull ? '' : 'NOT '
            );
        }

        if ($criterion instanceof RawCriterion) {
            return $this->compileSubQuery($criterion->raw, $bindings);
        }

        throw new InvalidQueryException('The given criterion '.get_class($criterion).' is unknown');
    }
257523
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\ContentTypeIdentifier &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
1246482
public function scanLocations(array $criteria)
    {
        $uris = $this->locations->map(function ($location) use ($criteria) {
            /** @var Location $location */
            return $location->getURI($criteria);
        })->filter(function ($uri) {
            return false !== $uri;
        });
        
        // Fall back for absolute paths on current filesystem.
        if ($uris->isEmpty()) {
            foreach ($criteria as $criterion) {
                if (file_exists($criterion)) {
                    return $criterion;
                }
            }
        }

        return $uris->isEmpty() ? false : $uris->first();
    }
451279
public function matching(Criteria $criteria)
    {
        if ($this->isDirty) {
            $this->initialize();
        }

        if ($this->initialized) {
            return $this->collection->matching($criteria);
        }

        if ($this->association['type'] === ClassMetadata::MANY_TO_MANY) {
            $persister = $this->em->getUnitOfWork()->getCollectionPersister($this->association);

            return new ArrayCollection($persister->loadCriteria($this, $criteria));
        }

        $builder         = Criteria::expr();
        $ownerExpression = $builder->eq($this->backRefFieldName, $this->owner);
        $expression      = $criteria->getWhereExpression();
        $expression      = $expression ? $builder->andX($expression, $ownerExpression) : $ownerExpression;

        $criteria = clone $criteria;
        $criteria->where($expression);

        $persister = $this->em->getUnitOfWork()->getEntityPersister($this->association['targetEntity']);

        return ($this->association['fetch'] === ClassMetadataInfo::FETCH_EXTRA_LAZY)
            ? new LazyCriteriaCollection($persister, $criteria)
            : new ArrayCollection($persister->loadCriteria($criteria));
    }
149864
public static function count($criteria = array())
    {
        self::processCriteriaWithType($criteria);
        $count = self::connection()->count(self::collectionName(), $criteria);
        return $count;
    }
417564
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\SectionId &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
134640
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof SectionIdentifierCriterion
            && (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
1080194
public function addCriterion(CriterionInterface $criterion, $name = null, $outerMode = Link::LINK_DEFAULT)
    {
        if (null !== $return = $this->validateMethodCall()) {
            return $return;
        }

        $criterionGroup = new CriterionGroup();
        $criterionGroup->addCriterion($criterion, $name);

        return $this->addCriterionGroup($criterionGroup, $name, $outerMode);
    }