@param bool $onlyActive

@return \Doctrine\ORM\QueryBuilder
972442
private function getQueryBuilder($onlyActive = true)
    {
        $em = $this->getEntityManager();

        $qb = $em->getRepository('EcommerceBundle:Product')
            ->createQueryBuilder('p');

        if ($onlyActive) {
            $qb->where('p.active = true');
        }

        return $qb;
    }
116745
protected function getFilterArray($onlyActive)
    {
        $cacheKey = ($onlyActive) ? 'public' : 'admin';
        if ($this->cache->tags(['blocks'])->has('blocks:filter:' . $cacheKey)) {
            return $this->cache->tags(['blocks'])->get('blocks:filter:' . $cacheKey);
        } else {
            $blocks = $this->blockRepository->getBlocksWithFilter($onlyActive);
            $filter = $this->buildFilterArray($blocks);
            $this->cache->tags(['blocks'])->forever('blocks:filter:' . $cacheKey, $filter);
            return $filter;
        }
    }
256999
public function findLastPostQueryBuilder($limit)
    {
        return $this->createQueryBuilder()
            ->field('enabled')->equals(true)
            ->sort('createdAt', 'desc')
            ->limit($limit)
            ->getQuery()
            ->execute();
    }
967475
public function search($categoryId = null, $onlyVisible = false)
    {
        $query = static::find();
        if ($categoryId) {
            $query->andWhere(['category_id' => $categoryId]);
        }
        if ($onlyVisible) {
            $query->joinWith(['category' => function ($query) {
                $query->andWhere([Category::tableName() . '.visible' => 1]);
            }]);
            $query->andWhere([static::tableName() . '.visible' => 1]);
        }

        $dataProvider = new ActiveDataProvider(['query' => $query]);
        $dataProvider->sort->defaultOrder = ['sort' => SORT_ASC, 'id' => SORT_ASC];
        return $dataProvider;
    }
983543
public function getQueryBuilder() {
        $query = $this->query;

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

        return $query;
    }
819814
public function newQuery($excludeDeleted = true)
    {
        $builder = parent::newQuery($excludeDeleted);

        if ($this->isSubType())
        {
            $builder->where($this->typeField, $this->getClass($this->typeField));
        }

        return $builder;
    }
1323869
public function files($active = true)
    {
        $query = $this->morphToMany(File::class, 'uploadable')
        ->with('translations')
        ->withPivot('weight')
        ->orderBy('weight', 'ASC')
        ->withTimestamps();

        if ($active) {
            $query->where('is_active', '=', 1);
        }

        return $query;
    }
1354565
public function active($active)
    {
        $model = $this->noInitModel;
        if (!is_string($model->statusAttribute)) {
            return $this;
        }
        return $this->andWhere([$model->statusAttribute => $active]);
    }
620990
private function getFilterFieldActive($isActive)
    {
        $request = $this->getRequest();

        if ($request->query->has('is_active')) {
            $isActive = $request->query->get('is_active');
        }

        $oViewRenderer = new ViewRenderer();
        $oViewRenderer->AddSourceObject('sInputClass', 'form-control input-sm submitOnSelect');
        $oViewRenderer->AddSourceObject('sName', 'is_active');
        $oViewRenderer->AddSourceObject('sLabelText', $this->getTranslation('chameleon_system_shop.list_manager_article.filter_active_label'));
        $oViewRenderer->AddSourceObject('sValue', $isActive);
        $oViewRenderer->AddSourceObject('autoWidth', true);

        $aValueList = array();
        $aValueList[] = array('sName' => $this->getTranslation('chameleon_system_shop.list_manager_article.filter_active_all'), 'sValue' => 'all');
        $aValueList[] = array('sName' => $this->getTranslation('chameleon_system_shop.list_manager_article.filter_active_only_active'), 'sValue' => '1');
        $aValueList[] = array('sName' => $this->getTranslation('chameleon_system_shop.list_manager_article.filter_active_only_inactive'), 'sValue' => '0');

        $oViewRenderer->AddSourceObject('aValueList', $aValueList);

        return $oViewRenderer->Render('userInput/form/select.html.twig', null, false);
    }
772712
public function findOneByHost($hostname, $onlyActive = false)
    {
        $allMatchingDomains = $this->findByHost($hostname, $onlyActive);
        return count($allMatchingDomains) > 0 ? $allMatchingDomains[0] : null;
    }
202621
public function getQueryBuilder()
    {
        if (!is_object($this->_queryBuilder)) {
            $this->_queryBuilder = Yii::createObject($this->_queryBuilder, [$this]);
        }
        return $this->_queryBuilder;
    }
849643
public function toArrayFrontend($prefixed = true, array $only = [])
    {
        $only = array_merge($only, $this->frontend);

        return $this->toArray($prefixed, $only);
    }
1037636
protected function buildCondition(
        Contracts\QueryEntity $meta,
        Builder $query,
        array $condition,
        $boolean = 'and'
    )
    {
        $fields = $meta->getFields();
        if (array_key_exists('data', $condition) && array_key_exists('relation', $condition['data'])) {
            $type = $fields[$condition['data']['relation']]->getType();
            if ($type instanceof Types\Relation) {
                $meta = $type->getEntity();
            } else {
                throw new RuntimeException("Field {$condition['data']['relation']} is not instance of Types\Relation");
            }
            $method = $boolean === 'or' ? 'orWhereHas' : 'whereHas';
            $query->{$method}($condition['data']['relation'], function (Builder $query) use ($meta, $condition) {
                $query->where(function (Builder $query) use ($meta, $condition) {
                    $this->getSubQuery($meta, $query, $condition['rules'], $condition['condition']);
                });
            }, ($condition['not'] ?? false ? '<' : '>='), $condition['data']['count'] ?? 1);
        } elseif (array_key_exists('condition', $condition)) {
            $query->where(function (Builder $query) use ($meta, $condition) {
                $this->getSubQuery($meta, $query, $condition['rules'], $condition['condition']);
            }, null, null, $boolean);
        } elseif (array_key_exists($condition['field'], $fields)) {
            $this->applyFilter(
                $query,
                $fields[$condition['field']],
                $condition['operator'],
                $condition['value'] ?? null,
                $boolean
            );
        } else {
            throw new RuntimeException("Field {$condition['field']} not found.");
        }
    }
1084938
public function isActive($active = true)
    {
        if (! is_bool($active)) {
            $active = false;
        }
        $this->isActive = $active;

        return $this;
    }
1203724
protected function createFindQuery(): QueryBuilder
    {
        $query = $this->connection->createQueryBuilder();
        $query
            ->select('id', 'locale', 'name', 'disabled')
            ->from('ezcontent_language');

        return $query;
    }
910463
public function getQueryBuilder()
    {
        if ( ! $this->queryBuilder instanceof AbstractQueryBuilder) {
            $className = str_replace('Connection', 'QueryBuilder', get_called_class());

            if (class_exists($className)) {
                $this->queryBuilder = new $className($this);
            }
        }

        return $this->queryBuilder;
    }
62234
public function useSiteHashFromAllowedSites($allowedSites): QueryBuilder
    {
        $isAnySiteAllowed = trim($allowedSites) === '*';
        if ($isAnySiteAllowed) {
            // no filter required
            return $this;
        }

        $allowedSites = GeneralUtility::trimExplode(',', $allowedSites);
        $filters = [];
        foreach ($allowedSites as $site) {
            $siteHash = $this->siteHashService->getSiteHashForDomain($site);
            $filters[] = 'siteHash:"' . $siteHash . '"';
        }

        $siteHashFilterString = implode(' OR ', $filters);
        return $this->useFilter($siteHashFilterString, 'siteHash');
    }