public function findBy(array $criteria, array $sorting = null, $limit = null, $offset = null)
    {
        $queryBuilder = $this->getCollectionQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);
        $this->applySorting($queryBuilder, (array) $sorting);

        if (null !== $limit) {
            $queryBuilder->setMaxResults($limit);
        }

        if (null !== $offset) {
            $queryBuilder->setFirstResult($offset);
        }

        $query = $queryBuilder->getQuery();

        if (null !== $limit) {
            return $this->collectionResult($query);
        }

        return $query->getResult();
    }
public function findBy(array $criteria, array $sorting = null, $limit = null, $offset = null)
    {
        $queryBuilder = $this->getCollectionQueryBuilder();

        $this->applyCriteria($queryBuilder, $criteria);
        $this->applySorting($queryBuilder, (array) $sorting);

        if (null !== $limit) {
            $queryBuilder->setMaxResults($limit);
        }

        if (null !== $offset) {
            $queryBuilder->setFirstResult($offset);
        }

        $query = $queryBuilder->getQuery();

        if (null !== $limit) {
            return $this->collectionResult($query);
        }

        return $query->getResult();
    }
public function findBy ( array $ criteria , array $ sorting = null , $ limit = null , $ offset = null ) { $ queryBuilder = $ this -> getCollectionQueryBuilder ( ) ; $ this -> applyCriteria ( $ queryBuilder , $ criteria ) ; $ this -> applySorting ( $ queryBuilder , ( array ) $ sorting ) ; if ( null !== $ limit ) { $ queryBuilder -> setMaxResults ( $ limit ) ; } if ( null !== $ offset ) { $ queryBuilder -> setFirstResult ( $ offset ) ; } $ query = $ queryBuilder -> getQuery ( ) ; if ( null !== $ limit ) { return $ this -> collectionResult ( $ query ) ; } return $ query -> getResult ( ) ; }
Finds resources by criteria, sorting, limit and offset.

@param array $criteria
@param array $sorting
@param int   $limit
@param int   $offset

@return array|\Doctrine\ORM\Tools\Pagination\Paginator
Finds resources by criteria sorting limit and offset .