]> git.immae.eu Git - github/wallabag/wallabag.git/blame_incremental - src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
Fix title card HTML parsing
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / PreparePagerForEntries.php
... / ...
CommitLineData
1<?php
2
3namespace Wallabag\CoreBundle\Helper;
4
5use Pagerfanta\Adapter\AdapterInterface;
6use Pagerfanta\Pagerfanta;
7use Symfony\Component\Routing\Router;
8use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9use Wallabag\UserBundle\Entity\User;
10
11class PreparePagerForEntries
12{
13 private $router;
14 private $tokenStorage;
15
16 public function __construct(TokenStorageInterface $tokenStorage, Router $router)
17 {
18 $this->tokenStorage = $tokenStorage;
19 $this->router = $router;
20 }
21
22 /**
23 * @param AdapterInterface $adapter
24 * @param User $user If user isn't logged in, we can force it (like for rss)
25 *
26 * @return null|Pagerfanta
27 */
28 public function prepare(AdapterInterface $adapter, User $user = null)
29 {
30 if (null === $user) {
31 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
32 }
33
34 if (null === $user || !is_object($user)) {
35 return;
36 }
37
38 $entries = new Pagerfanta($adapter);
39 $entries->setMaxPerPage($user->getConfig()->getItemsPerPage());
40
41 return $entries;
42 }
43}