public function paginate($perPage = 25, QueryParameters $queryParameters = null, $currentPage = null, $searchQuery = null) {
        $currentPage = $currentPage === null ? $this->paginator->getCurrentPage() : $currentPage;

        $qb = $this->addSearchConditions($this->createSelectQuery(), $searchQuery);

        $qb = $qb->setFirstResult($perPage * ($currentPage - 1))
                 ->setMaxResults($perPage);
        $items = $this->getQuery($qb, $queryParameters)->getResult();

        $count = $this->addSearchConditions($this->createCountQuery(), $searchQuery);
        $count = (int) $this->getQuery($count, $queryParameters)->getSingleScalarResult();

        return $this->paginator->make($items, $count, $perPage);
    }
public function paginate($perPage = 25, QueryParameters $queryParameters = null, $currentPage = null, $searchQuery = null) {
        $currentPage = $currentPage === null ? $this->paginator->getCurrentPage() : $currentPage;

        $qb = $this->addSearchConditions($this->createSelectQuery(), $searchQuery);

        $qb = $qb->setFirstResult($perPage * ($currentPage - 1))
                 ->setMaxResults($perPage);
        $items = $this->getQuery($qb, $queryParameters)->getResult();

        $count = $this->addSearchConditions($this->createCountQuery(), $searchQuery);
        $count = (int) $this->getQuery($count, $queryParameters)->getSingleScalarResult();

        return $this->paginator->make($items, $count, $perPage);
    }
public function paginate ( $ perPage = 25 , QueryParameters $ queryParameters = null , $ currentPage = null , $ searchQuery = null ) { $ currentPage = $ currentPage === null ? $ this -> paginator -> getCurrentPage ( ) : $ currentPage ; $ qb = $ this -> addSearchConditions ( $ this -> createSelectQuery ( ) , $ searchQuery ) ; $ qb = $ qb -> setFirstResult ( $ perPage * ( $ currentPage - 1 ) ) -> setMaxResults ( $ perPage ) ; $ items = $ this -> getQuery ( $ qb , $ queryParameters ) -> getResult ( ) ; $ count = $ this -> addSearchConditions ( $ this -> createCountQuery ( ) , $ searchQuery ) ; $ count = ( int ) $ this -> getQuery ( $ count , $ queryParameters ) -> getSingleScalarResult ( ) ; return $ this -> paginator -> make ( $ items , $ count , $ perPage ) ; }
Retrieves all entities, by page.

@param int             $perPage          items per page
@param QueryParameters $queryParameters  an optional array of query scopes
@param int             $currentPage      current page that overrides the pagination service
@return mixed
Retrieves all entities by page .