]>
Commit | Line | Data |
---|---|---|
891456ba NL |
1 | <?php |
2 | ||
3 | namespace Wallabag\CoreBundle\Helper; | |
4 | ||
5 | use Pagerfanta\Adapter\AdapterInterface; | |
6 | use Pagerfanta\Pagerfanta; | |
7 | use Symfony\Component\Routing\Router; | |
8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | |
9 | ||
10 | class PreparePagerForEntries | |
11 | { | |
12 | private $user; | |
13 | private $router; | |
14 | ||
15 | public function __construct(TokenStorage $token, Router $router) | |
16 | { | |
17 | $this->user = $token->getToken()->getUser(); | |
18 | $this->router = $router; | |
19 | } | |
20 | ||
21 | /** | |
22 | * @param AdapterInterface $adapter | |
23 | * @param int $page | |
24 | * | |
25 | * @return null|Pagerfanta | |
26 | */ | |
27 | public function prepare(AdapterInterface $adapter, $page = 1) | |
28 | { | |
29 | $entries = new Pagerfanta($adapter); | |
30 | $entries->setMaxPerPage($this->user->getConfig()->getItemsPerPage()); | |
31 | ||
32 | return $entries; | |
33 | } | |
34 | } |