eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriterionHandler\FieldRelation::handle PHP Method

handle() public method

accept() must be called before calling this method.
public handle ( CriteriaConverter $converter, eZ\Publish\Core\Persistence\Database\SelectQuery $query, eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion, array $languageSettings ) : eZ\Publish\Core\Persistence\Database\Expression
$converter eZ\Publish\Core\Search\Legacy\Content\Common\Gateway\CriteriaConverter
$query eZ\Publish\Core\Persistence\Database\SelectQuery
$criterion eZ\Publish\API\Repository\Values\Content\Query\Criterion
$languageSettings array
return eZ\Publish\Core\Persistence\Database\Expression
    public function handle(CriteriaConverter $converter, SelectQuery $query, Criterion $criterion, array $languageSettings)
    {
        $column = $this->dbHandler->quoteColumn('to_contentobject_id', 'ezcontentobject_link');
        $fieldDefinitionIds = $this->getFieldDefinitionsIds($criterion->target);
        switch ($criterion->operator) {
            case Criterion\Operator::CONTAINS:
                if (count($criterion->value) > 1) {
                    $subRequest = array();
                    foreach ($criterion->value as $value) {
                        $subSelect = $query->subSelect();
                        $subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
                        $subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'), $fieldDefinitionIds), $subSelect->expr->eq($column, $value)));
                        $subRequest[] = $subSelect->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect);
                    }
                    return $query->expr->lAnd($subRequest);
                }
                // Intentionally omitting break
            // Intentionally omitting break
            case Criterion\Operator::IN:
                $subSelect = $query->subSelect();
                $subSelect->select($this->dbHandler->quoteColumn('from_contentobject_id'))->from($this->dbHandler->quoteTable('ezcontentobject_link'));
                return $query->expr->in($this->dbHandler->quoteColumn('id', 'ezcontentobject'), $subSelect->where($subSelect->expr->lAnd($subSelect->expr->eq($this->dbHandler->quoteColumn('from_contentobject_version', 'ezcontentobject_link'), $this->dbHandler->quoteColumn('current_version', 'ezcontentobject')), $subSelect->expr->in($this->dbHandler->quoteColumn('contentclassattribute_id', 'ezcontentobject_link'), $fieldDefinitionIds), $subSelect->expr->in($column, $criterion->value))));
            default:
                throw new RuntimeException("Unknown operator '{$criterion->operator}' for RelationList criterion handler.");
        }
    }