nsm/doctrine-paginator

Simple decorator for Doctrine Paginator

1.0.0 2017-08-22 14:13 UTC

README

Simple decorator for \Doctrine\ORM\Tools\Pagination\Paginator.

Usage

// $qb is a Doctrine QueryBuilder object
$p = new \Nsm\DoctrinePaginator\DoctrinePaginator($qb);

var_dump(
    array(
        'currentPageNumber' => $p->getCurrentPageNumber(),
        'currentPageResults' => $p->getCurrentPageResults(),
        'currentPageResultCount' => $p->getCurrentPageResultCount(),
        'currentPageFirstResultPositionInTotalResults' => $p->getCurrentPageFirstResultPositionInTotalResults(),
        'currentPageLastResultPositionInTotalResults' => $p->getCurrentPageLastResultPositionInTotalResults(),
        'maxPageNumber' => $p->getMaxPerPageNumber(),
        'hasPreviousPage' => $p->hasPreviousPage($pNum),
        'previousPageNumber' => $p->hasPreviousPage($pNum) ? $p->getPreviousPageNumber($pNum) : false,
        'hasNextPage' => $p->hasNextPage($pNum),
        'nextPageNumber' => $p->hasNextPage($pNum) ? $p->getNextPageNumber($pNum) : false,
        'totalPageCount' => $p->getTotalPageCount(),
        'totalResultCount' => $p->getTotalResultCount(),
        'canPaginate' => $p->canPaginate(),
        'pageRangeForPage' => $p->getPageRangeForPage(3)
     )
);

Running Tests

composer install
bin/phpspec run