3 namespace Wallabag\CoreBundle\Helper
;
5 use Pagerfanta\Adapter\AdapterInterface
;
6 use Pagerfanta\Pagerfanta
;
7 use Symfony\Component\Routing\Router
;
8 use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface
;
10 class PreparePagerForEntries
13 private $tokenStorage;
15 public function __construct(TokenStorageInterface
$tokenStorage, Router
$router)
17 $this->tokenStorage
= $tokenStorage;
18 $this->router
= $router;
22 * @param AdapterInterface $adapter
25 * @return null|Pagerfanta
27 public function prepare(AdapterInterface
$adapter, $page = 1)
29 $user = $this->tokenStorage
->getToken() ? $this->tokenStorage
->getToken()->getUser() : null;
31 if (null === $user || !is_object($user)) {
35 $entries = new Pagerfanta($adapter);
36 $entries->setMaxPerPage($user->getConfig()->getItemsPerPage());