Skip to content

Commit

Permalink
Replaced Zend paginator with Pagerfanta
Browse files Browse the repository at this point in the history
  • Loading branch information
overgapo committed Jul 30, 2014
1 parent 908a205 commit 88337c2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 0 additions & 3 deletions Controller/PhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;

use Zend\Paginator\Paginator;
use Zend\Paginator\Adapter\ArrayAdapter;

use FOQ\AlbumBundle\Model\AlbumInterface;
use FOQ\AlbumBundle\Document\Photo;

Expand Down
16 changes: 7 additions & 9 deletions Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Doctrine\ODM\MongoDB\Query\Builder;

use Zend\Paginator\Paginator;
use ZendPaginatorAdapter\DoctrineMongoDBAdapter;
use Zend\Paginator\Adapter\ArrayAdapter;
use Pagerfanta\Pagerfanta;
use Pagerfanta\Adapter\DoctrineODMMongoDBAdapter;
use Pagerfanta\Adapter\ArrayAdapter;

abstract class AbstractProvider
{
Expand Down Expand Up @@ -57,15 +57,13 @@ protected function getUser($username)
protected function paginate($data)
{
if ($data instanceof Builder) {
$adapter = new DoctrineMongoDBAdapter($data);
$adapter = new DoctrineODMMongoDBAdapter($data);
} else {
$adapter = new ArrayAdapter($data);
}
$paginator = new Paginator($adapter);

$paginator->setCurrentPageNumber($this->request->get('page', 1));
$paginator->setItemCountPerPage($this->getItemCountPerPage());
$paginator->setPageRange($this->getPageRange());
$paginator = new Pagerfanta($adapter);
$paginator->setCurrentPage($this->request->get('page', 1));
$paginator->setMaxPerPage($this->getItemCountPerPage());

return $paginator;
}
Expand Down
3 changes: 0 additions & 3 deletions Provider/PhotoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Doctrine\ODM\MongoDB\Query\Builder;
use Doctrine\ODM\MongoDB\DocumentManager;
use Zend\Paginator\Paginator;
use ZendPaginatorAdapter\DoctrineMongoDBAdapter;
use Zend\Paginator\Adapter\ArrayAdapter;

/**
* High level object finder that uses the route parameters as method arguments
Expand Down

0 comments on commit 88337c2

Please sign in to comment.