Filter QueryBuilder with online.

@param \Doctrine\DBAL\Query\QueryBuilder $query_builder
@return \Doctrine\DBAL\Query\QueryBuilder
760932
protected function filterOnlines(\Doctrine\ORM\QueryBuilder $query_builder = null) {

        if (!$query_builder)
            $query_builder = $this->createQueryBuilder('e');

        $query_builder->andWhere("e.nested_set = 1");
        return $query_builder;
    }
503220
public function query() : Builder
	{
		if (! is_null($this->min) && ! is_null($this->max)) {
			$this->builder->whereBetween('price', [$this->min, $this->max]);
		}

		if (! is_null($this->min) && is_null($this->max)) {
			$this->builder->where('price', '>=', $this->min);
		}

		if (is_null($this->min) && ! is_null($this->max)) {
			$this->builder->where('price', '<=', $this->max);
		}

		return $this->builder;
	}
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;
    }
1233825
public function setQueryBuilder($queryBuilder)
    {
        if (!is_object($queryBuilder)) {
            throw new InvalidQueryBuilderObject('Parameter must be an object of "\Doctrine\ORM\QueryBuilder" or "Doctrine\ODM\MongoDB\Query\Builder"');
        }

        if (!$queryBuilder instanceof QueryBuilder && !$queryBuilder instanceof Builder) {
            throw new InvalidQueryBuilderObject(sprintf('%s is not valid query builder object', get_class($queryBuilder)));
        }

        $this->queryBuilder = $queryBuilder;
    }
1198849
public function query() : Builder
	{
		if (trim($seed = $this->seed) !== '') {
			$this->builder->where(function ($query) use ($seed) {
				return $this->resolveQuery($query, $seed);
			});
		}

		return $this->builder;
	}
462797
public function buildQueryBuilder()
    {
        $builder = new QueryBuilder();

        foreach ($this->parsers as $parser) {
            if ($parser->wasApplied()) {
                $parser->apply($builder);
            }
        }

        foreach ($this->sorts as $sort) {
            $builder->orderBy($sort[0], $sort[1]);
        }

        if (!empty($this->perPage)) {
            $builder->setPageSize($this->perPage);
        }

        if (!empty($this->page)) {
            $builder->setPage($this->page);
        }

        if (!empty($this->searchQuery)) {
            $builder->setSearchQuery($this->searchQuery);
        }

        return $builder;
    }
1312191
protected function filterQueryBuilder(QueryBuilder $queryBuilder, string $field, ListFilter $listFilter)
    {
        $value = $this->filterEasyadminAutocompleteValue($listFilter->getValue());
        // Empty string and numeric keys is considered as "not applied filter"
        if (null === $value || '' === $value || \is_int($field)) {
            return;
        }

        // Add root entity alias if none provided
        $queryField = $listFilter->getProperty();
        if (false === \strpos($queryField, '.')) {
            $queryField = $queryBuilder->getRootAlias().'.'.$queryField;
        }

        // Checks if filter is directly appliable on queryBuilder
        if (!$this->isFilterAppliable($queryBuilder, $queryField)) {
            return;
        }

        $operator = $listFilter->getOperator();
        // Sanitize parameter name
        $parameter = 'form_filter_'.\str_replace('.', '_', $field);

        switch ($operator) {
            case ListFilter::OPERATOR_EQUALS:
                if ('_NULL' === $value) {
                    $queryBuilder->andWhere(\sprintf('%s IS NULL', $queryField));
                } elseif ('_NOT_NULL' === $value) {
                    $queryBuilder->andWhere(\sprintf('%s IS NOT NULL', $queryField));
                } else {
                    $queryBuilder
                        ->andWhere(\sprintf('%s %s :%s', $queryField, '=', $parameter))
                        ->setParameter($parameter, $value)
                    ;
                }
                break;
            case ListFilter::OPERATOR_NOT:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, '!=', $parameter))
                    ->setParameter($parameter, $value)
                ;
                break;
            case ListFilter::OPERATOR_IN:
                // Checks that $value is not an empty Traversable
                if (0 < \count($value)) {
                    $queryBuilder
                        ->andWhere(\sprintf('%s %s (:%s)', $queryField, 'IN', $parameter))
                        ->setParameter($parameter, $value)
                    ;
                }
                break;
            case ListFilter::OPERATOR_NOTIN:
                // Checks that $value is not an empty Traversable
                if (0 < \count($value)) {
                    $queryBuilder
                        ->andWhere(\sprintf('%s %s (:%s)', $queryField, 'NOT IN', $parameter))
                        ->setParameter($parameter, $value)
                    ;
                }
                break;
            case ListFilter::OPERATOR_GT:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, '>', $parameter))
                    ->setParameter($parameter, $value)
                ;
                break;
            case ListFilter::OPERATOR_GTE:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, '>=', $parameter))
                    ->setParameter($parameter, $value)
                ;
                break;
            case ListFilter::OPERATOR_LT:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, '<', $parameter))
                    ->setParameter($parameter, $value)
                ;
                break;
            case ListFilter::OPERATOR_LTE:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, '<=', $parameter))
                    ->setParameter($parameter, $value)
                ;
                break;
            case ListFilter::OPERATOR_LIKE:
                $queryBuilder
                    ->andWhere(\sprintf('%s %s :%s', $queryField, 'LIKE', $parameter))
                    ->setParameter($parameter, '%'.$value.'%')
                ;
                break;
            default:
                throw new \RuntimeException(\sprintf('Operator "%s" is not supported !', $operator));
        }
    }
1166503
private function filter(Builder $query): Builder
    {
        $filters = $this->entity->getFilters();

        foreach ($filters as $filter) {
            $query = $filter->filter($query);
        }

        return $query;
    }
862916
public function search(QueryBuilderInterface $Builder) {
        $this->serialyse($Builder);
        $statement = $this->connector->query($this->parsedQuery);
        $result    = $this->statementToArray($statement);
        $resultSetClass = $this->resultSetClassName;
        $resultSet = new $resultSetClass($result);
        $queryCount = $this->getSerialyser()->setCriteriaList($Builder)->count(true)->serialyse();
        $resultSet->setParent($this)->setCountQuery($queryCount);
        return $resultSet;
    }
528542
public function setQueryBuilder(QueryBuilder $queryBuilder, $alias)
    {
        $this->queryBuilder = $queryBuilder;
        $this->alias = $alias;

        return $this;
    }
301876
public function getQueryBuilder()
    {
        /** @var $queryBuilder QueryBuilder */
        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getQueryBuilderForTable('tx_gridelements_backend_layout');
        $queryBuilder->getRestrictions()
            ->removeAll()
            ->add(GeneralUtility::makeInstance(DeletedRestriction::class))
            ->add(GeneralUtility::makeInstance(HiddenRestriction::class));
        return $queryBuilder;
    }
748204
protected function applyFormFilters(QueryBuilder $queryBuilder, array $filters = [])
    {
        foreach ($filters as $field => $listFilter) {
            if (null === $listFilter) {
                continue;
            }

            $this->filterQueryBuilder($queryBuilder, $field, $listFilter);
        }
    }
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;
	}
899161
public function setBaseQueryBuilder(QueryBuilder $baseQueryBuilder=null)
    {
        if($baseQueryBuilder === null)
        {
            $this->baseQueryBuilder = $this->getDefaultQueryBuilder();
        }
        else
        {
            $this->baseQueryBuilder = $baseQueryBuilder;
        }
    }
983543
public function getQueryBuilder() {
        $query = $this->query;

        if ($query instanceof \Illuminate\Database\Eloquent\Builder)
        {
            $query = $query->getQuery();
        }

        return $query;
    }
698567
protected function addFilters(QueryBuilder $queryBuilder, $filters = array())
    {
        foreach ($filters as $field => $value) {
            $methodName = sprintf('add%sFilter', ucfirst($field));
            if (method_exists($this, $methodName)) {
                // This field has a custom filtering method
                $this->$methodName($queryBuilder, $value);
                continue;
            }

            if (null === $value || '' === $value || (is_array($value) && 0 == count($value))) {
                // Skip: value is blank
                continue;
            }

            $field = $this->addEntityAlias($field);
            if (is_array($value)) {
                $queryBuilder->andWhere($queryBuilder->expr()->in($field, $value));
            } else {
                $queryBuilder->andWhere($queryBuilder->expr()->eq($field, $queryBuilder->expr()->literal($value)));
            }
        }

        return $queryBuilder;
    }
353329
public function query() : Builder
	{
		if (is_null($this->category_id)) {
			return $this->builder;
		}

		if (count($children = $this->children()) > 0) {
			$this->builder->whereIn('category_id', $children);
		}

		return $this->builder;
	}