Check if visitor is applicable to current criterion.

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

@return bool
513836
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\RemoteId &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ
            );
    }
471024
public function isPorn($threshold = FALSE) {
        return $threshold === FALSE
            ? $this->quantifyYCbCr() >= $this->threshold
            : $this->quantifyYCbCr() >= $threshold;
    }
770782
protected function applyCriteria($criteria)
    {
        $query = $this->getQuery();
        $metadata = $this->getEntityMetadata();
        
        if (null !== $criteria) {
            switch (true) {
                case is_scalar($criteria):
                    $identifier = $metadata->getRawSQLName($metadata->getIdentifier());
                    $query->addConditions($identifier, $criteria);
                    break;
                
                case $criteria instanceof QueryBuilder\Select:
                    $criteria->setFromTable($metadata->getTableName());
                    $this->setQuery($criteria);
                    break;
                
                case (is_array($criteria) and count($criteria) > 0):
                    $query->addConditions(...$criteria);
                    break;
                
                default:
                    throw new NotSupportedException('It is impossible to determine the correct assignment criteria');
                    break;
            }
        }
        
        return $this;
    }
1219694
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\Field &&
            (
                ($criterion->operator ?: Operator::IN) === Operator::IN ||
                $criterion->operator === Operator::EQ ||
                $criterion->operator === Operator::CONTAINS
            );
    }
343627
protected function getTotalCount(Criterion $criterion, array $languageFilter)
    {
        $query = $this->handler->createSelectQuery();
        $query
            ->select($query->alias($query->expr->count('*'), 'count'))
            ->from($this->handler->quoteTable('ezcontentobject_tree'))
            ->innerJoin(
                'ezcontentobject',
                'ezcontentobject_tree.contentobject_id',
                'ezcontentobject.id'
            )
            ->innerJoin(
                'ezcontentobject_version',
                'ezcontentobject.id',
                'ezcontentobject_version.contentobject_id'
            );

        $query->where(
            $this->criteriaConverter->convertCriteria($query, $criterion, $languageFilter),
            $query->expr->eq(
                'ezcontentobject.status',
                //ContentInfo::STATUS_PUBLISHED
                $query->bindValue(1, null, PDO::PARAM_INT)
            ),
            $query->expr->eq(
                'ezcontentobject_version.status',
                //VersionInfo::STATUS_PUBLISHED
                $query->bindValue(1, null, PDO::PARAM_INT)
            ),
            $query->expr->neq(
                $this->handler->quoteColumn('depth', 'ezcontentobject_tree'),
                $query->bindValue(0, null, PDO::PARAM_INT)
            )
        );

        // If not main-languages query
        if (!empty($languageFilter['languages'])) {
            $query->where(
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->handler->quoteColumn('language_mask', 'ezcontentobject'),
                        $query->bindValue(
                            $this->getLanguageMask($languageFilter),
                            null,
                            PDO::PARAM_INT
                        )
                    ),
                    $query->bindValue(0, null, PDO::PARAM_INT)
                )
            );
        }

        $statement = $query->prepare();
        $statement->execute();

        return (int)$statement->fetchColumn();
    }
1107702
public function add(CriterionInterface $criterion): self
    {
        if (! $criterion->isAttached()) {
            $criterion->attach($this);
        }

        $this->criteria[] = $criterion;

        return $this;
    }
73398
public function canVisit(Criterion $criterion)
    {
        return
            $criterion instanceof Criterion\Location\IsMainLocation && $criterion->operator === Operator::EQ;
    }
894972
public function matching(Criteria $criteria)
    {
        if ($this->isDirty) {
            $this->initialize();
        }

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

        if ($this->association instanceof ManyToManyAssociationMetadata) {
            $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->getTargetEntity());

        return $this->association->getFetchMode() === FetchMode::EXTRA_LAZY
            ? new LazyCriteriaCollection($persister, $criteria)
            : new ArrayCollection($persister->loadCriteria($criteria));
    }
1357841
protected function applyCriteria(Builder $builder, array $criteria)
    {
        foreach ($criteria as $criterion) {
            $criterion->apply($builder);
        }
    }
602676
protected function getQueryCondition(
        Criterion $filter,
        SelectQuery $query,
        array $languageFilter
    ) {
        $condition = $query->expr->lAnd(
            $this->criteriaConverter->convertCriteria($query, $filter, $languageFilter),
            $query->expr->eq(
                'ezcontentobject.status',
                ContentInfo::STATUS_PUBLISHED
            ),
            $query->expr->eq(
                'ezcontentobject_version.status',
                VersionInfo::STATUS_PUBLISHED
            )
        );

        // If not main-languages query
        if (!empty($languageFilter['languages'])) {
            $condition = $query->expr->lAnd(
                $condition,
                $query->expr->gt(
                    $query->expr->bitAnd(
                        $this->handler->quoteColumn('language_mask', 'ezcontentobject'),
                        $query->bindValue(
                            $this->getLanguageMask($languageFilter),
                            null,
                            PDO::PARAM_INT
                        )
                    ),
                    $query->bindValue(0, null, PDO::PARAM_INT)
                )
            );
        }

        return $condition;
    }
1055826
protected function getCondition(Criterion $criterion)
    {
        if (count($criterion->value) > 1) {
            return array(
                'terms' => array(
                    'locations_doc.remote_id_id' => $criterion->value,
                ),
            );
        } else {
            return array(
                'term' => array(
                    'locations_doc.remote_id_id' => $criterion->value[0],
                ),
            );
        }
    }
1349588
protected function isAttributeMatching(array $criterion)
	{
		if ( !isset($criterion[self::CRITERION_ATTRS]) ) {
			return true;
		}

		foreach ( $criterion[self::CRITERION_ATTRS] as $attribute => $definition ) {
			if ( $this->isValueMatchingCriterionDefinition($this->getAttribute($attribute), $definition) ) {
				return true;
			}
		}

		return false;
	}
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');
    }
1083928
public function matching(Criteria $criteria)
    {
        $clause = [];
        /** @var Comparison $whereClause */
        $whereClause = $criteria->getWhereExpression();
        if (null !== $whereClause) {
            if (Comparison::EQ !== $whereClause->getOperator()) {
                throw new \InvalidArgumentException(sprintf('Support for Selectable is limited to the EQUALS "=" operator, 
                 % given', $whereClause->getOperator()));
            }

            $clause = [$whereClause->getField() => $whereClause->getValue()->getValue()];
        }

        return $this->findBy($clause, $criteria->getOrderings(), $criteria->getMaxResults(), $criteria->getFirstResult());
    }
1351239
public function addAnd(AbstractCriterion $criterion)
    {
        $this->clauses[] = $criterion;
        $this->conjunctions[] = self::UND;

        return $this;
    }
206944
public function equals($crit)
    {
        if (null === $crit || !($crit instanceof Criteria)) {
            return false;
        }

        /** @var Criteria $crit */
        if ($this === $crit) {
            return true;
        }

        if ($this->size() === $crit->size()) {

            // Important: nested criterion objects are checked

            $criteria = $crit; // alias
            if  ($this->offset            === $criteria->getOffset()
                && $this->limit           === $criteria->getLimit()
                && $this->ignoreCase      === $criteria->isIgnoreCase()
                && $this->singleRecord    === $criteria->isSingleRecord()
                && $this->dbName          === $criteria->getDbName()
                && $this->selectModifiers === $criteria->getSelectModifiers()
                && $this->selectColumns   === $criteria->getSelectColumns()
                && $this->asColumns       === $criteria->getAsColumns()
                && $this->orderByColumns  === $criteria->getOrderByColumns()
                && $this->groupByColumns  === $criteria->getGroupByColumns()
                && $this->aliases         === $criteria->getAliases()
               ) // what about having ??
            {
                foreach ($criteria->keys() as $key) {
                    if ($this->containsKey($key)) {
                        $a = $this->getCriterion($key);
                        $b = $criteria->getCriterion($key);
                        if (!$a->equals($b)) {
                            return false;
                        }
                    } else {
                        return false;
                    }
                }

                $joins = $criteria->getJoins();
                if (count($joins) != count($this->joins)) {
                    return false;
                }

                foreach ($joins as $key => $join) {
                    if (!$join->equals($this->joins[$key])) {
                        return false;
                    }
                }

                return true;
            } else {
                return false;
            }
        }

        return false;
    }
156754
public function addCriterion(CriterionInterface $criterion, $name = null, $link = Link::LINK_AND)
    {
        if (null === $name) {
            $this->collection[] = [$criterion, $link];
        } else {
            $this->collection[$this->resolveString($name, __METHOD__)] = [$criterion, $link];
        }

        $this->collectionCount++;

        return $this;
    }