diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-07 10:34:49 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-07 10:34:49 +0100 |
commit | 2fe2e411a74d541ddd7eee2aca1b80ac58de49eb (patch) | |
tree | 41751ffe85c4073ceec34fbf688fb9dcfc7babc2 /src | |
parent | 24692715de6be93d3d01606624003cef4d170133 (diff) | |
download | wallabag-2fe2e411a74d541ddd7eee2aca1b80ac58de49eb.tar.gz wallabag-2fe2e411a74d541ddd7eee2aca1b80ac58de49eb.tar.zst wallabag-2fe2e411a74d541ddd7eee2aca1b80ac58de49eb.zip |
Replaced TokenStorage with TokenStorageInterface
Diffstat (limited to 'src')
-rw-r--r-- | src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | 10 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php | 16 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 3c597b5d..f7fbd2ec 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |||
@@ -13,6 +13,7 @@ use Symfony\Component\Form\AbstractType; | |||
13 | use Symfony\Component\Form\FormBuilderInterface; | 13 | use Symfony\Component\Form\FormBuilderInterface; |
14 | use Symfony\Component\OptionsResolver\OptionsResolver; | 14 | use Symfony\Component\OptionsResolver\OptionsResolver; |
15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | 15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; |
16 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
16 | 17 | ||
17 | class EntryFilterType extends AbstractType | 18 | class EntryFilterType extends AbstractType |
18 | { | 19 | { |
@@ -25,10 +26,15 @@ class EntryFilterType extends AbstractType | |||
25 | * @param EntityRepository $entryRepository | 26 | * @param EntityRepository $entryRepository |
26 | * @param TokenStorage $token | 27 | * @param TokenStorage $token |
27 | */ | 28 | */ |
28 | public function __construct(EntityRepository $entryRepository, TokenStorage $token) | 29 | public function __construct(EntityRepository $entryRepository, TokenStorageInterface $tokenStorage) |
29 | { | 30 | { |
30 | $this->repository = $entryRepository; | 31 | $this->repository = $entryRepository; |
31 | $this->user = $token->getToken()->getUser(); | 32 | |
33 | $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; | ||
34 | |||
35 | if (null === $this->user || !is_object($this->user)) { | ||
36 | return null; | ||
37 | } | ||
32 | } | 38 | } |
33 | 39 | ||
34 | public function buildForm(FormBuilderInterface $builder, array $options) | 40 | 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; | |||
5 | use Pagerfanta\Adapter\AdapterInterface; | 5 | use Pagerfanta\Adapter\AdapterInterface; |
6 | use Pagerfanta\Pagerfanta; | 6 | use Pagerfanta\Pagerfanta; |
7 | use Symfony\Component\Routing\Router; | 7 | use Symfony\Component\Routing\Router; |
8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | 8 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
9 | 9 | ||
10 | class PreparePagerForEntries | 10 | class 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 | } |