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
;
9 use Wallabag\UserBundle\Entity\User
;
11 class PreparePagerForEntries
14 private $tokenStorage;
16 public function __construct(TokenStorageInterface
$tokenStorage, Router
$router)
18 $this->tokenStorage
= $tokenStorage;
19 $this->router
= $router;
23 * @param AdapterInterface $adapter
24 * @param User $user If user isn't logged in, we can force it (like for rss)
26 * @return null|Pagerfanta
28 public function prepare(AdapterInterface
$adapter, User
$user = null)
31 $user = $this->tokenStorage
->getToken() ? $this->tokenStorage
->getToken()->getUser() : null;
34 if (null === $user || !is_object($user)) {
38 $entries = new Pagerfanta($adapter);
39 $entries->setMaxPerPage($user->getConfig()->getItemsPerPage());