aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-07 11:13:50 +0100
committerGitHub <noreply@github.com>2016-11-07 11:13:50 +0100
commita4de2351a0fbae735cad234ca8a50bdee7632b68 (patch)
tree9a5092609c015de6a55470f4ea447aab3bb29d31 /src/Wallabag
parent06283bef72a0fcc6004dc69e014146486ba210bc (diff)
parent94766a89627df74449b9e34d31a06db386a1b07a (diff)
downloadwallabag-a4de2351a0fbae735cad234ca8a50bdee7632b68.tar.gz
wallabag-a4de2351a0fbae735cad234ca8a50bdee7632b68.tar.zst
wallabag-a4de2351a0fbae735cad234ca8a50bdee7632b68.zip
Merge pull request #2556 from wallabag/replace-tokenstorage
Replaced TokenStorage with TokenStorageInterface
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php15
-rw-r--r--src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php16
2 files changed, 21 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index 3c597b5d..a3e36fdd 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -12,7 +12,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
12use Symfony\Component\Form\AbstractType; 12use Symfony\Component\Form\AbstractType;
13use Symfony\Component\Form\FormBuilderInterface; 13use Symfony\Component\Form\FormBuilderInterface;
14use Symfony\Component\OptionsResolver\OptionsResolver; 14use Symfony\Component\OptionsResolver\OptionsResolver;
15use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 15use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
16 16
17class EntryFilterType extends AbstractType 17class EntryFilterType extends AbstractType
18{ 18{
@@ -22,13 +22,18 @@ class EntryFilterType extends AbstractType
22 /** 22 /**
23 * Repository & user are used to get a list of language entries for this user. 23 * Repository & user are used to get a list of language entries for this user.
24 * 24 *
25 * @param EntityRepository $entryRepository 25 * @param EntityRepository $entryRepository
26 * @param TokenStorage $token 26 * @param TokenStorageInterface $tokenStorage
27 */ 27 */
28 public function __construct(EntityRepository $entryRepository, TokenStorage $token) 28 public function __construct(EntityRepository $entryRepository, TokenStorageInterface $tokenStorage)
29 { 29 {
30 $this->repository = $entryRepository; 30 $this->repository = $entryRepository;
31 $this->user = $token->getToken()->getUser(); 31
32 $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
33
34 if (null === $this->user || !is_object($this->user)) {
35 return null;
36 }
32 } 37 }
33 38
34 public function buildForm(FormBuilderInterface $builder, array $options) 39 public function buildForm(FormBuilderInterface $builder, array $options)
diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
index f9066bee..7d3798b9 100644
--- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
+++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
@@ -5,16 +5,16 @@ namespace Wallabag\CoreBundle\Helper;
5use Pagerfanta\Adapter\AdapterInterface; 5use Pagerfanta\Adapter\AdapterInterface;
6use Pagerfanta\Pagerfanta; 6use Pagerfanta\Pagerfanta;
7use Symfony\Component\Routing\Router; 7use Symfony\Component\Routing\Router;
8use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 8use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9 9
10class PreparePagerForEntries 10class PreparePagerForEntries
11{ 11{
12 private $user;
13 private $router; 12 private $router;
13 private $tokenStorage;
14 14
15 public function __construct(TokenStorage $token, Router $router) 15 public function __construct(TokenStorageInterface $tokenStorage, Router $router)
16 { 16 {
17 $this->user = $token->getToken()->getUser(); 17 $this->tokenStorage = $tokenStorage;
18 $this->router = $router; 18 $this->router = $router;
19 } 19 }
20 20
@@ -26,8 +26,14 @@ class PreparePagerForEntries
26 */ 26 */
27 public function prepare(AdapterInterface $adapter, $page = 1) 27 public function prepare(AdapterInterface $adapter, $page = 1)
28 { 28 {
29 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
30
31 if (null === $user || !is_object($user)) {
32 return null;
33 }
34
29 $entries = new Pagerfanta($adapter); 35 $entries = new Pagerfanta($adapter);
30 $entries->setMaxPerPage($this->user->getConfig()->getItemsPerPage()); 36 $entries->setMaxPerPage($user->getConfig()->getItemsPerPage());
31 37
32 return $entries; 38 return $entries;
33 } 39 }