{@inheritdoc}
@see \Oka\PaginationBundle\Converter\QueryExprConverter::apply()
357173
public function apply($dbDriver, $alias, $field, $exprValue, $namedParameter = null, &$value = null)
	{
		$matches = [];
		
		if (!preg_match(self::PATTERN, $exprValue, $matches)) {
			throw new BadQueryExprException(sprintf('The query expression converter "range" does not support the following pattern "%s".', $exprValue));
		}
		
		switch (true) {
			case $matches[2] && !$matches[3]:
				return $this->createGreaterExpr($field, $matches[1], trim($matches[2]));
				
			case !$matches[2] && $matches[3]:
				return $this->createLessExpr($field, $matches[4], trim($matches[3]));
				
			case $matches[2] && $matches[3]:
				return (new \Doctrine\MongoDB\Query\Expr())->addAnd(
						$this->createGreaterExpr($field, $matches[1], trim($matches[2])), 
						$this->createLessExpr($field, $matches[4], trim($matches[3]))
					);
				
			default:
				throw new BadQueryExprException('the range query expression converter requires left or right value of range');
		}
	}
1277557
public function apply(Query $query) : Query
    {
        $method = is_array($this->value) ? 'in' : 'eq';

        return $query->where(
            (new QueryExpression())->{$method}(
                $this->field,
                [] === $this->value ? '' : $this->value,
                $query->getTypeMap()->type($this->field)
            )
        );
    }
84610
public function apply(ModelCriteria $query)
    {
        if ($this->query) {
            $query->mergeWith($this->query);
        }

        return $query;
    }
142504
public function apply()
    {
        $input = $this->grid->getInputProcessor()->getInput();
        $sort = null;
        if (isset($input['sort'])) {
            foreach ($input['sort'] as $field => $direction) {
                $sort = [$field, $direction];
                break;
            }
        }
        foreach ($this->grid->getConfig()->getColumns() as $column) {
            if ($sort) {
                if ($column->getName() === $sort[0]) {
                    $column->setSorting($sort[1]);
                } else {
                    $column->setSorting(null);
                }
            } else {
                if ($direction = $column->getSorting()) {
                    $sort = [$column->getName(), $direction];
                }
            }
        }
        if ($sort) {
            $this
                ->grid
                ->getConfig()
                ->getDataProvider()
                ->orderBy($sort[0], $sort[1]);
        }
    }
550933
public function apply($queryBuilder, JoinMap $joinMap): ?string
    {
        $alias = null;

        $executedAliases = $queryBuilder->getAllAliases();
        foreach ($joinMap->getJoinMap() as $path => $fields) {
            foreach ($fields as $fieldData) {
                $field         = $fieldData['field'];
                $hasSelect     = $fieldData['hasSelect'];
                $selectFields  = $fieldData['selectFields'];
                $joinType      = $fieldData['joinType'];
                $conditionType = $fieldData['conditionType'];
                $condition     = $fieldData['condition'];

                $pathAlias = str_replace('.', '_', $path);
                $alias     = $pathAlias . '_' . $field;
                $join      = $pathAlias . '.' . $field;

                if (in_array($alias, $executedAliases)) {
                    continue;
                }

                if ($hasSelect) {
                    if (!$selectFields) {
                        $queryBuilder->addSelect($alias);

                    } else {
                        $queryBuilder->addSelect(sprintf('PARTIAL %s.{%s}', $alias, implode(',', $selectFields)));
                    }
                }

                if ($joinType == JoinMap::JOIN_TYPE_LEFT) {
                    $queryBuilder->leftJoin($join, $alias, $conditionType, $condition);

                } elseif ($joinType == JoinMap::JOIN_TYPE_INNER) {
                    $queryBuilder->innerJoin($join, $alias, $conditionType, $condition);

                } else {
                    throw new \RuntimeException('Join type not defined or has wrong type.');
                }
            }
        }

        return $alias;
    }
331437
private function applyRqlQuery()
    {
        $rqlQuery = $this->getRqlQuery();

        // Setting RQL Query
        if ($rqlQuery) {
            // Check if search and if this Repository have search indexes.
            if ($query = $rqlQuery->getQuery()) {
                if ($query instanceof AndNode) {
                    foreach ($query->getQueries() as $xq) {
                        if ($xq instanceof SearchNode && !$this->hasSearchIndex()) {
                            throw new \InvalidArgumentException('Search operation not supported on this endpoint');
                        }
                    }
                } elseif ($query instanceof SearchNode && !$this->hasSearchIndex()) {
                    throw new \InvalidArgumentException('Search operation not supported on this endpoint');
                }
            }

            $this->visitor->setRepository($this->repository);
            $this->queryBuilder = $this->visitor->visit($rqlQuery);
        }

        if (is_null($this->getDocumentId()) && $this->queryBuilder instanceof Builder) {

            /*** default sort ***/
            if (!array_key_exists('sort', $this->queryBuilder->getQuery()->getQuery())) {
                $this->queryBuilder->sort('_id');
            }

            /*** pagination stuff ***/
            if (!array_key_exists('limit', $this->queryBuilder->getQuery()->getQuery())) {
                $this->queryBuilder->skip($this->getPaginationSkip());
                $this->queryBuilder->limit($this->getPaginationPageSize());
            }
        }
    }
844598
public function apply()
    {
        $value = $this->getValue();
        if (null === $value || '' === $value) {
            return;
        }
        if ($func = $this->config->getFilteringFunc()) {
            $func($value, $this->grid->getConfig()->getDataProvider());
            return;
        }
        $isLike = $this->config->getOperator() === FilterConfig::OPERATOR_LIKE;
        if ($isLike && strpos($value, '%') === false) {
            $value = "%$value%";
        }
        $this->grid->getConfig()->getDataProvider()->filter(
            $this->config->getName(),
            $this->config->getOperator(),
            $value
        );
    }
865941
public function process(ExprBuilder $builder, $field, $expression, $value)
    {
        if (!Expr::isValidExpression($expression)) {
            throw new ParserException(sprintf(
                'The expression "%s" is not allowed or not exists.',
                $expression
            ));
        }

        switch ($expression) {
            case 'between':
                set_error_handler(function () use ($value) {
                    throw new ParserException(sprintf(
                        'The value of "between" expression "%s" is not valid.',
                        $value
                    ));
                });

                list($from, $to) = explode('-', $value);

                restore_error_handler();

                return $builder->between($field, $from, $to);
            case 'paginate':
                set_error_handler(function () use ($value) {
                    throw new ParserException(sprintf(
                        'The value of "paginate" expression "%s" is not valid.',
                        $value
                    ));
                });

                list($currentPageNumber, $maxResultsPerPage) = explode('-', $value);

                restore_error_handler();

                return $builder->paginate($currentPageNumber, $maxResultsPerPage);
            case 'or':
                return $builder->orx($value);
            default:
                return $builder->{$expression}($field, $value);
        }
    }
823640
public function apply()
    {
        $records = $this->getDraftRecords();
        
        if ($ids = $this->getLiveIds()) {
            $records = $records->exclude('ID', $ids);
        }
        
        return $records;
    }
987746
public function applySort()
    {
        if ($this->sortable === false) {
            return;
        }

        $sortBy = $this->getSortBy();

        if ($sortBy && $this->paginator) {
            $this->paginator->addReloadArgs([$this->name.'_sort' => $sortBy]);
        }

        $desc = false;
        if ($sortBy && $sortBy[0] == '-') {
            $desc = true;
            $sortBy = substr($sortBy, 1);
        }

        $this->table->sortable = true;

        if (
            $sortBy
            && isset($this->table->columns[$sortBy])
            && $this->model->hasElement($sortBy) instanceof \atk4\data\Field
        ) {
            $this->model->setOrder($sortBy, $desc);
            $this->table->sort_by = $sortBy;
            $this->table->sort_order = $desc ? 'descending' : 'ascending';
        }

        $this->table->on(
            'click',
            'thead>tr>th',
            new jsReload($this->container, [$this->name.'_sort' => (new jQuery())->data('column')])
        );
    }
1323550
public function apply(
        QueryBuilder $queryBuilder,
        QueryNameGeneratorInterface $queryNameGenerator,
        string $resourceClass,
        string $operationName = null
    ) {
        $request = $this->requestStack->getCurrentRequest();
        if (null === $request) {
            return;
        }
        $requestProperties = $this->extractProperties($request);
        if (!array_key_exists('order', $requestProperties)) {
            return;
        }

        /** @var array $orderProperties */
        $orderProperties = $requestProperties['order'];
        $this->doApply($queryBuilder, $orderProperties, $resourceClass, $operationName);
    }
1075975
protected function applyScope()
    {
        foreach ($this->scopeQuery as $callback) {
            if (is_callable($callback)) {
                $this->query = $callback($this->query);
            }
        }

        // Clear scopes
        $this->scopeQuery = [];

        return $this;
    }
325501
public function apply(object $object, ReflectionProperty $reflectionProperty, callable $objectCopier): void
    {
        $reflectionProperty->setAccessible(true);
        /** @var Collection $oldCollection */
        $oldCollection = $reflectionProperty->getValue($object);

        $newCollection = $oldCollection->map(
            function ($item) use ($objectCopier) {
                return $objectCopier($item);
            }
        );

        $reflectionProperty->setValue($object, $newCollection);
    }
234071
private function applyNestedFilter(Builder $query, array $fields, $operator, $value, $or = false)
    {
        $relation_name = implode('.', array_slice($fields, 0, count($fields) - 1));
        $relation_field = end($fields);
        if ($relation_name[0] == '!') {
            $relation_name = substr($relation_name, 1, strlen($relation_name));

            $that = $this;

            return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) {
                $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or);
            }, '=', 0);
        }

        $that = $this;

        return $query->whereHas($relation_name, function ($query) use ($relation_field, $operator, $value, $that, $or) {
            $query = $that->applyWhereClause($query, $relation_field, $operator, $value, $or);
        });
    }
471412
public function apply($name, $value, $query, FilterInterface $filter)
    {
        $column = $this->translationTable . '.'
                . ( ! empty($this->column) ? $this->column : $name);

        $operator = '=';

        if ( ! $this->exact) {
            $operator = 'LIKE';
            $value    = '%' . $value . '%';
        }

        $query->where($this->translationTable . '.locale', $this->locale)
              ->where($column, $operator, $value);


        // add a join for the translations
        $filter->addJoin(
            JoinKey::TRANSLATIONS,
            [
                $this->translationTable,
                $this->translationTable . '.' . str_singular($this->table) . '_id',
                '=',
                $this->table . '.id'
            ]
        );

        return $query;
    }
319206
public function apply()
    {
        if ($this->canApply()) {
            $subject = $this->getSubject();
            $parent = $subject->getParent();
            $node = $this->createNode($parent);

            $node->moveAfter($subject);
            $this->updateWorkspaceInfo();
        }
    }
240014
public function apply(Builder $query)
    {
        $this->specificationSet->applyAll($query);
        $this->sortingSet->applyAll($query);
        $this->paramSet->apply($query);
    }