Entity/EntityRepository.php
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;
    }
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;
    }
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 ; }
Adds filters to the QueryBuilder instance.

@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param array $filters
@return \Doctrine\ORM\QueryBuilder
Adds filters to the QueryBuilder instance .