src/Phlexible/Bundle/MessageBundle/Entity/Repository/MessageRepository.php
private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
    {
        if ($criteria->getMode() === Criteria::MODE_OR) {
            $expr = $qb->expr()->orX();
        } else {
            $expr = $qb->expr()->andX();
        }
        foreach ($criteria as $criterium) {
            if ($criterium instanceof Criteria) {
                $expr->add(
                    $this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
                );
            } else {
                $this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
            }
        }

        return $expr;
    }
private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
    {
        if ($criteria->getMode() === Criteria::MODE_OR) {
            $expr = $qb->expr()->orX();
        } else {
            $expr = $qb->expr()->andX();
        }
        foreach ($criteria as $criterium) {
            if ($criterium instanceof Criteria) {
                $expr->add(
                    $this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
                );
            } else {
                $this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
            }
        }

        return $expr;
    }
private function applyCriteriaToQueryBuilder ( Criteria $ criteria , QueryBuilder $ qb , $ prefix ) { if ( $ criteria -> getMode ( ) === Criteria :: MODE_OR ) { $ expr = $ qb -> expr ( ) -> orX ( ) ; } else { $ expr = $ qb -> expr ( ) -> andX ( ) ; } foreach ( $ criteria as $ criterium ) { if ( $ criterium instanceof Criteria ) { $ expr -> add ( $ this -> applyCriteriaToQueryBuilder ( $ criterium , $ qb , $ prefix ) ) ; } else { $ this -> applyCriteriumToQueryBuilder ( $ criterium , $ qb , $ expr , $ prefix ) ; } } return $ expr ; }
Apply criteria to select.

@param Criteria     $criteria
@param QueryBuilder $qb
@param string       $prefix

@return Composite
Apply criteria to select .