Apply criteria in current Query

@return $this
326263
protected function applyCriteria()
    {

        if ($this->skipCriteria === true) {
            return $this;
        }

        $criteria = $this->getCriteria();

        if ($criteria) {
            foreach ($criteria as $c) {
                if ($c instanceof CriteriaInterface) {
                    $this->model = $c->apply($this->model, $this);
                }
            }
        }

        return $this;
    }
1016420
function() {

    if (!this._alreadyInitiallyExpandedCriteria) {
      this._wlQueryInfo.criteria = expandWhereShorthand(this._wlQueryInfo.criteria);
      this._alreadyInitiallyExpandedCriteria = true;
    }//>-

    this._wlQueryInfo.criteria.max = arguments[0];

    return this;
  }
847041
public function resetQuery()
    {
        $this->_field_list = array(self::DEFAULT_FIELD);
        $this->_param_list = array();
        $this->_limit      = array(self::DEFAULT_LIMIT);
        $this->_where_list = array();

        return $this;
    }
1344348
public function setQuery($query)
    {
        $this->query = $query;
        parse_str($this->query, $this->query_array);
        return $this;
    }
1058150
public function bindWhere()
    {
        if (count($this->wheresBindValue) > 0) {
            foreach ($this->wheresBindValue as $value) {
                $bindDataType = $this->bindDataType($value[2]);
                $this->sqlQuery->bindValue($this->positioningMarker, $value[2], $bindDataType);

                $this->positioningMarker++;
            }
        }

        return $this;
    }
398070
protected function applySort()
    {
        $sort = $this->getActualSort();

        if ( ! $sort) return $this;

        $criteria = $this->getModelSortCriteria();

        if ( ! $criteria) return $this;

        $this->getModelRepository()->pushCriteria($criteria, CriteriaKey::ORDER);

        return $this;
    }
682169
public function where($sql=null, $params=array())
    {
        $this->_where = new Criteria($sql, $params);

        return $this;
    }
750960
public function apply($query)
    {
        $this->forgetJoins();

        $this->applyParameters($query);

        $this->applyJoins($query);

        return $query;
    }
136265
public function buildCriteria()
    {
        $criteria = new Criteria(C2MTableMap::DATABASE_NAME);

        if ($this->isColumnModified(C2MTableMap::COL_CATEGORY_ID)) {
            $criteria->add(C2MTableMap::COL_CATEGORY_ID, $this->category_id);
        }
        if ($this->isColumnModified(C2MTableMap::COL_MEDIA_ID)) {
            $criteria->add(C2MTableMap::COL_MEDIA_ID, $this->media_id);
        }

        return $criteria;
    }
1075975
protected function applyScope()
    {
        foreach ($this->scopeQuery as $callback) {
            if (is_callable($callback)) {
                $this->query = $callback($this->query);
            }
        }

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

        return $this;
    }
1295282
public function setQueries(array $query = []) : self
    {
        if (sizeof($query) == 0) {
            $this->uri['query'] = [];
        } else {
            $this->uri['query'] = $query;
        }

        return $this;
    }
886576
protected function setSearchCriteriaFromQuery()
    {
        $this->initSearchCriteria();

        foreach ($this->aCriteria as $sIndex => $mValue) {
            $this->aCriteria[$sIndex] = $this->app['request']->query->get($sIndex, $mValue);
        }
    }
192284
public function buildCriteria()
    {
        $criteria = new Criteria(UserRoleTableMap::DATABASE_NAME);

        if ($this->isColumnModified(UserRoleTableMap::COL_USER_ID)) {
            $criteria->add(UserRoleTableMap::COL_USER_ID, $this->user_id);
        }
        if ($this->isColumnModified(UserRoleTableMap::COL_ROLE_ID)) {
            $criteria->add(UserRoleTableMap::COL_ROLE_ID, $this->role_id);
        }

        return $criteria;
    }
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());
            }
        }
    }
805134
public function applyJoin()
    {
        if ($this->skipJoin) {
            return $this;
        }
        $attributeCode = $this->attribute->getCode();
        if ($this->joinApplied) {
            throw new \LogicException("Join for attribute query builder {$attributeCode} already applied");
        }
        $qb = $this->eavQueryBuilder->getQueryBuilder();

        // Join based on attributeCode
        $attributeParameter = $this->generateUniqueId('attribute');
        $qb->setParameter($attributeParameter, $attributeCode);
        $joinDql = "{$this->joinAlias}.attributeCode = :{$attributeParameter}";

        if ($this->enforceFamilyCondition) {
            $family = $this->attribute->getFamily();
            if (!$family) {
                throw new MissingFamilyException("Unable to resolve family for attribute {$attributeCode}");
            }
            $familyParameter = $this->generateUniqueId('family');
            $qb->setParameter($familyParameter, $family->getCode());
            $joinDql .= " AND {$this->joinAlias}.familyCode = :{$familyParameter}";
        }

        if ($this->context) {
            /** @var ContextualValueInterface $valueClass */
            $valueClass = $this->attribute->getFamily()->getValueClass();
            if (!is_a($valueClass, ContextualValueInterface::class, true)) {
                throw new ContextException('Unable to filter by context on a non-contextual value class');
            }
            foreach ($this->context as $axis => $axisValues) {
                if (!\in_array($axis, $valueClass::getContextKeys(), true)) {
                    throw new ContextException("Trying to filter on invalid axis '{$axis}'");
                }
                if (!\in_array($axis, $this->attribute->getContextMask(), true)) {
                    continue;
                }
                $axisValueParameter = $this->generateUniqueId($axis.'Axis');
                $joinDql .= " AND {$this->joinAlias}.{$axis}";
                if (is_array($axisValues)) {
                    $joinDql .= " IN (:{$axisValueParameter})";
                } else {
                    $joinDql .= " = :{$axisValueParameter}";
                }
                $qb->setParameter($axisValueParameter, $axisValues);
            }
        }

        $qb->leftJoin(
            $this->eavQueryBuilder->getAlias().'.values',
            $this->joinAlias,
            Join::WITH,
            $joinDql
        );

        if ($this->joinRelation) {
            $qb->leftJoin(
                $this->joinAlias.'.'.$this->attribute->getType()->getDatabaseType(),
                $this->joinRelation
            );
        }

        $this->joinApplied = true;

        return $this;
    }
154699
public function buildQuery()
    {
        $this->setSelectFrom();
        $this->setLeftJoins($this->qb);
        $this->setWhere($this->qb);
        $this->setWhereResultCallback($this->qb);
        $this->setWhereAllCallback($this->qb);
        $this->setOrderBy();
        $this->setLimit();

        return $this;
    }
646871
protected function finishQuery() {
        
        $this->query .= ' ' . $this->addLimit($this->criteriaList->getLimit() , $this->criteriaList->getOffset()) .' ) ' . 
                $this->operationSeparator .
                $this->getDriverEscaper()->dbCommand('AS') .
                ' subQuery ) ' . $this->operationSeparator . 
                $this->addSort($this->criteriaList->getSort());
        
        return $this;
    }