Returns a collection of items by CompositeExpression.
D

@param CompositeExpression|null $expression Optional expression to filter records.
@param QueryBuilder|null $queryBuilder QueryBuilder to use
@return array
196025
protected function getItemsByCompositeExpression(CompositeExpression $expression = null, QueryBuilder $queryBuilder = null) : array
    {
        if (!$queryBuilder instanceof QueryBuilder) {
            $queryBuilder = $this->getQueryBuilder();
        }

        $queryBuilder->select('*')->from($this->table);
        if (isset($expression)) {
            $queryBuilder->where($expression);
        }

        $indexQueueItemRecords = $queryBuilder->execute()->fetchAll();
        return $this->getIndexQueueItemObjectsFromRecords($indexQueueItemRecords);
    }
649055
public function subquery( QueryBuilder $queryBuilder ) {
		$this->subqueries[] = $queryBuilder->getSPARQL( false );
		$this->usageValidator->trackDefinedVariables( implode( ' ', $queryBuilder->getSelects() ) );

		// @todo temp hack to add AS definitions to defined variables
		$regexHelper = new RegexHelper();
		$matches = $regexHelper->getMatches( 'AS \{variable}', implode( ' ', $queryBuilder->getSelects() ) );
		$this->usageValidator->trackDefinedVariables( $matches );

		return $this;
	}
143205
public function filter(array $constraints = [], string $shape = null, QueryBuilder $qb = null)
    {
        $qb = !is_null($qb) ? $qb : $this->createQueryBuilder('e');
        return $this->arrange($this->_by($qb, $constraints), $shape);
    }
408881
public function getTree(QueryBuilder $builder)
    {
        $query = Content::with(self::$loadRelations);

        if (optional($builder->getFilter('only_categories'))->getValue()) {
            $query->join('content_types as ct', 'contents.type_id', '=', 'ct.id');
            $query->where('ct.name', 'category');
        }

        $builder = (new QueryBuilder())->orderBy('translations.title', 'asc');

        $query->orderBy('level', 'ASC');

        $builder->applySorts($query, 'contents');

        $results = $query->distinct()->get(['contents.*']);
        $trees   = (new Content)->buildTree($results, true);
        if ($trees === null) {
            return collect([]);
        }
        if (!$trees instanceof Collection) {
            return collect([$trees]);
        }
        return $trees;
    }
436820
private static function filterInOrNotInList($operation, QueryBuilder $queryBuilder)
    {
        $expressionMethod = lcfirst(preg_replace('/\s+/', '', ucwords(strtolower($operation['operation']))));

        return $queryBuilder
            ->expr()
            ->{$expressionMethod}($operation['property'], $operation['values']);
    }
1339723
public function useFiltersFromTypoScript(): QueryBuilder
    {
        $filters = Filters::fromTypoScriptConfiguration($this->typoScriptConfiguration);
        $this->queryToBuild->setFilterQueries($filters->getValues());

        $this->useFilterArray($this->getAdditionalFilters());

        $searchQueryFilters = $this->typoScriptConfiguration->getSearchQueryFilterConfiguration();

        if (!is_array($searchQueryFilters) || count($searchQueryFilters) <= 0) {
            return $this;
        }

        // special filter to limit search to specific page tree branches
        if (array_key_exists('__pageSections', $searchQueryFilters)) {
            $pageIds = GeneralUtility::trimExplode(',', $searchQueryFilters['__pageSections']);
            $this->usePageSectionsFromPageIds($pageIds);
            $this->typoScriptConfiguration->removeSearchQueryFilterForPageSections();
        }

        return $this;
    }
273701
public function findBy(array $criteria)
    {
        if (false == $criteria) {
            return [];
        }

        $modelClass = $this->modelClass;

        /** @var Builder $query */
        $query = null;
        foreach ($criteria as $name => $value) {
            if (false == $query) {
                $query = $modelClass::where($name, '=', $value);
            }

            $query->where($name, '=', $value);
        }

        return iterator_to_array($query->get());
    }
1036193
public function getFilter($key, $value = null)
    {
        if (!$this->expr instanceof ExpressionBuilder) {
            throw new QueryParseException('Cannot call method without an Expression Builder parameter set', 1);
        }

        /** @var callable $callback */
        foreach ($this->filterHandlers as $callback) {
            $result = $callback($key, $value, $this->expr);
            if ($result instanceof Filter) {
                return $result;
            }
        }

        return null;
    }
1261925
private function fetchExpression($expression)
    {
        $selectors = explode(',', $expression);
        $paths = [];

        foreach ($selectors as $selector) {
            $selector = trim($selector);

            if (array_key_exists($selector, $this->compiledExpressions)) {
                $paths[] = $this->compiledExpressions[ $selector ];

                continue;
            }

            $this->compiledExpressions[ $selector ] = $this->fetchCssExpression($selector);

            $paths[] = $this->compiledExpressions[ $selector ];
        }

        return implode('|', $paths);
    }
281576
public function buildExpression(Expression $expr = null)
    {
        if (!$this->defaultExpression) {
            $this->defaultExpression = Expr::method('isEnabled', Expr::same(true))
                ->andMethod('getTypeName', Expr::same(DiscoveryUrlGenerator::BINDING_TYPE))
                ->andMethod('getBinding', Expr::method('getQuery', Expr::endsWith('{,/**/*}')));
        }

        if (!$expr) {
            return $this->defaultExpression;
        }

        $traverser = new ExpressionTraverser();
        $traverser->addVisitor($this);

        return $this->defaultExpression->andX($traverser->traverse($expr));
    }
250853
public static function filter(array $collection, $expression, array $context = [])
    {
        $language = new ExpressionLanguage();

        $result = [];
        foreach ($collection as $key => $item) {
            if ($language->evaluate($expression, array_merge($context, ['item' => $item, 'key' => $key]))) {
                $result[$key] = $item;
            }
        }

        return $result;
    }
762997
public function getDSQLExpression($expression)
    {
        if (!$this->owner->persistence || !$this->owner->persistence instanceof Persistence\SQL) {
            throw new Exception([
                'Field must have SQL persistence if it is used as part of expression',
                'persistence'=> $this->owner->persistence ?? null,
            ]);
        }

        return $this->owner->persistence->getFieldSQLExpression($this, $expression);
    }
1023396
public function getFilter(QueryBuilder $qb, $dqlAlias)
    {
        if ($this->child instanceof Filter) {
            $qb->having($this->child->getFilter($qb, $dqlAlias));
        } else {
            $qb->having($this->child);
        }
    }
80552
public function getQuery(QueryBuilder $queryBuilder)
    {
        $rule = $this->getRule();
        $activeFrom = $rule->getActiveFrom();
        $activeUntil = $rule->getActiveUntil();

        $resultQueryBuilder = $queryBuilder;

        if (!is_null($activeFrom)) {
            $resultQueryBuilder = $resultQueryBuilder
                ->andWhere('l.dateLog >= :activeFrom')
                ->setParameter(
                    'activeFrom',
                    $activeFrom->format('Y-m-d H:i:s')
                );
        }
        if (!is_null($activeUntil)) {
            $resultQueryBuilder = $resultQueryBuilder
                ->andWhere('l.dateLog <= :activeUntil')
                ->setParameter(
                    'activeUntil',
                    $activeUntil->format('Y-m-d H:i:s')
                );
        }

        return $resultQueryBuilder;
    }
1044714
private static function determineFilterAndOr(array $filter, QueryBuilder $queryBuilder)
    {
        if (!\in_array($filter['operation'], ['AND', 'OR'])) {
            return null;
        }

        static::filterAndOr($filter, $queryBuilder);

        return '';
    }
590271
public static List<OrderByItem> getOrderByItems(JPQLExpression jpqlExpression)
    {
        List<OrderByItem> orderList = new LinkedList<>();

        if (hasOrderBy(jpqlExpression))
        {
            Expression orderByItems = getOrderByClause(jpqlExpression).getOrderByItems();

            if (orderByItems instanceof CollectionExpression)
            {
                ListIterator<Expression> iterator = orderByItems.children().iterator();
                while (iterator.hasNext())
                {
                    OrderByItem orderByItem = (OrderByItem) iterator.next();
                    orderList.add(orderByItem);
                }
            }
            else
            {
                orderList.add((OrderByItem) orderByItems);
            }
        }

        return orderList;
    }
1097055
public function getFilter(QueryBuilder $qb, $dqlAlias)
    {
        if (null !== $this->dqlAlias) {
            $dqlAlias = $this->dqlAlias;
        }

        $field = ArgumentToOperandConverter::toField($this->field);

        return (string) $qb->expr()->isNotNull($field->transform($qb, $dqlAlias));
    }