public function createListQueryBuilder(array $entityConfig, $sortField = null, $sortDirection = null, $dqlFilter = null)
    {
        /* @var EntityManager $em */
        $em = $this->doctrine->getManagerForClass($entityConfig['class']);
        /* @var ClassMetadata $classMetadata */
        $classMetadata = $em->getClassMetadata($entityConfig['class']);
        /* @var DoctrineQueryBuilder $queryBuilder */
        $queryBuilder = $em->createQueryBuilder()
            ->select('entity')
            ->from($entityConfig['class'], 'entity')
        ;

        $isSortedByDoctrineAssociation = $this->isDoctrineAssociation($classMetadata, $sortField);
        if ($isSortedByDoctrineAssociation) {
            $sortFieldParts = \explode('.', $sortField);
            $queryBuilder->leftJoin('entity.'.$sortFieldParts[0], $sortFieldParts[0]);
        }

        if (!empty($dqlFilter)) {
            $queryBuilder->andWhere($dqlFilter);
        }

        if (null !== $sortField) {
            $queryBuilder->orderBy(\sprintf('%s%s', $isSortedByDoctrineAssociation ? '' : 'entity.', $sortField), $sortDirection);
        }

        return $queryBuilder;
    }
public function createListQueryBuilder(array $entityConfig, $sortField = null, $sortDirection = null, $dqlFilter = null)
    {
        /* @var EntityManager $em */
        $em = $this->doctrine->getManagerForClass($entityConfig['class']);
        /* @var ClassMetadata $classMetadata */
        $classMetadata = $em->getClassMetadata($entityConfig['class']);
        /* @var DoctrineQueryBuilder $queryBuilder */
        $queryBuilder = $em->createQueryBuilder()
            ->select('entity')
            ->from($entityConfig['class'], 'entity')
        ;

        $isSortedByDoctrineAssociation = $this->isDoctrineAssociation($classMetadata, $sortField);
        if ($isSortedByDoctrineAssociation) {
            $sortFieldParts = \explode('.', $sortField);
            $queryBuilder->leftJoin('entity.'.$sortFieldParts[0], $sortFieldParts[0]);
        }

        if (!empty($dqlFilter)) {
            $queryBuilder->andWhere($dqlFilter);
        }

        if (null !== $sortField) {
            $queryBuilder->orderBy(\sprintf('%s%s', $isSortedByDoctrineAssociation ? '' : 'entity.', $sortField), $sortDirection);
        }

        return $queryBuilder;
    }
public function createListQueryBuilder ( array $ entityConfig , $ sortField = null , $ sortDirection = null , $ dqlFilter = null ) { /* @var EntityManager $em */ $ em = $ this -> doctrine -> getManagerForClass ( $ entityConfig [ 'class' ] ) ; /* @var ClassMetadata $classMetadata */ $ classMetadata = $ em -> getClassMetadata ( $ entityConfig [ 'class' ] ) ; /* @var DoctrineQueryBuilder $queryBuilder */ $ queryBuilder = $ em -> createQueryBuilder ( ) -> select ( 'entity' ) -> from ( $ entityConfig [ 'class' ] , 'entity' ) ; $ isSortedByDoctrineAssociation = $ this -> isDoctrineAssociation ( $ classMetadata , $ sortField ) ; if ( $ isSortedByDoctrineAssociation ) { $ sortFieldParts = \ explode ( '.' , $ sortField ) ; $ queryBuilder -> leftJoin ( 'entity.' . $ sortFieldParts [ 0 ] , $ sortFieldParts [ 0 ] ) ; } if ( ! empty ( $ dqlFilter ) ) { $ queryBuilder -> andWhere ( $ dqlFilter ) ; } if ( null !== $ sortField ) { $ queryBuilder -> orderBy ( \ sprintf ( '%s%s' , $ isSortedByDoctrineAssociation ? '' : 'entity.' , $ sortField ) , $ sortDirection ) ; } return $ queryBuilder ; }
Creates the query builder used to get all the records displayed by the
"list" view.

@param array       $entityConfig
@param string|null $sortField
@param string|null $sortDirection
@param string|null $dqlFilter

@return DoctrineQueryBuilder
Creates the query builder used to get all the records displayed by the list view .