protected function applyQueryFilters(QueryBuilder $queryBuilder, $alias = 'a', $filters = array())
    {
        foreach ($filters as $filter => $value) {
            if ($value) {
                $reader = new AnnotationReader();
                $reflProperty = new ReflectionProperty($this->getEntityClass(), $filter);
                $OneToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\OneToMany');
                $ManyToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\ManyToMany');
                if ($OneToMany || $ManyToMany) {
                    $queryBuilder->leftJoin($alias . '.' . $filter, $filter);
                    $queryBuilder->andWhere($filter . ' = :' . $filter);
                }
                else {
                    $queryBuilder->andWhere($alias . '.' . $filter . ' = :' . $filter);
                }
                $queryBuilder->setParameter($filter, $value);
            }
        }

        return $queryBuilder;
    }
protected function applyQueryFilters(QueryBuilder $queryBuilder, $alias = 'a', $filters = array())
    {
        foreach ($filters as $filter => $value) {
            if ($value) {
                $reader = new AnnotationReader();
                $reflProperty = new ReflectionProperty($this->getEntityClass(), $filter);
                $OneToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\OneToMany');
                $ManyToMany = $reader->getPropertyAnnotation($reflProperty, '\Doctrine\ORM\Mapping\ManyToMany');
                if ($OneToMany || $ManyToMany) {
                    $queryBuilder->leftJoin($alias . '.' . $filter, $filter);
                    $queryBuilder->andWhere($filter . ' = :' . $filter);
                }
                else {
                    $queryBuilder->andWhere($alias . '.' . $filter . ' = :' . $filter);
                }
                $queryBuilder->setParameter($filter, $value);
            }
        }

        return $queryBuilder;
    }
protected function applyQueryFilters ( QueryBuilder $ queryBuilder , $ alias = 'a' , $ filters = array ( ) ) { foreach ( $ filters as $ filter => $ value ) { if ( $ value ) { $ reader = new AnnotationReader ( ) ; $ reflProperty = new ReflectionProperty ( $ this -> getEntityClass ( ) , $ filter ) ; $ OneToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\OneToMany' ) ; $ ManyToMany = $ reader -> getPropertyAnnotation ( $ reflProperty , '\Doctrine\ORM\Mapping\ManyToMany' ) ; if ( $ OneToMany || $ ManyToMany ) { $ queryBuilder -> leftJoin ( $ alias . '.' . $ filter , $ filter ) ; $ queryBuilder -> andWhere ( $ filter . ' = :' . $ filter ) ; } else { $ queryBuilder -> andWhere ( $ alias . '.' . $ filter . ' = :' . $ filter ) ; } $ queryBuilder -> setParameter ( $ filter , $ value ) ; } } return $ queryBuilder ; }
Apply filters to query builder

@param QueryBuilder $queryBuilder Query builder instance
@param string $alias Root query alias
@param array $filters Associative array of filters values to apply

@return Doctrine\ORM\QueryBuilder
Apply filters to query builder