diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-07 10:26:05 +0100 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-11-16 23:07:34 +0100 |
commit | 65cd8a4a9a1d15d962033f58276005a5f7716f3a (patch) | |
tree | c0dd762b631ae22443fb5efba3b838aeee01f7af /src/Wallabag/CoreBundle/Helper | |
parent | f052f1fd57e51c8ae5ac17587636d608619a2057 (diff) | |
download | wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.gz wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.zst wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.zip |
Added tests
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/Redirect.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/Redirect.php b/src/Wallabag/CoreBundle/Helper/Redirect.php index 59172db4..82792aec 100644 --- a/src/Wallabag/CoreBundle/Helper/Redirect.php +++ b/src/Wallabag/CoreBundle/Helper/Redirect.php | |||
@@ -3,7 +3,7 @@ | |||
3 | namespace Wallabag\CoreBundle\Helper; | 3 | namespace Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Symfony\Component\Routing\Router; | 5 | use Symfony\Component\Routing\Router; |
6 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | 6 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; |
7 | use Wallabag\CoreBundle\Entity\Config; | 7 | use Wallabag\CoreBundle\Entity\Config; |
8 | 8 | ||
9 | /** | 9 | /** |
@@ -12,12 +12,13 @@ use Wallabag\CoreBundle\Entity\Config; | |||
12 | class Redirect | 12 | class Redirect |
13 | { | 13 | { |
14 | private $router; | 14 | private $router; |
15 | private $tokenStorage; | ||
15 | private $actionMarkAsRead; | 16 | private $actionMarkAsRead; |
16 | 17 | ||
17 | public function __construct(Router $router, TokenStorage $token) | 18 | public function __construct(Router $router, TokenStorageInterface $tokenStorage) |
18 | { | 19 | { |
19 | $this->router = $router; | 20 | $this->router = $router; |
20 | $this->actionMarkAsRead = $token->getToken()->getUser()->getConfig()->getActionMarkAsRead(); | 21 | $this->tokenStorage = $tokenStorage; |
21 | } | 22 | } |
22 | 23 | ||
23 | /** | 24 | /** |
@@ -28,7 +29,13 @@ class Redirect | |||
28 | */ | 29 | */ |
29 | public function to($url, $fallback = '') | 30 | public function to($url, $fallback = '') |
30 | { | 31 | { |
31 | if (Config::REDIRECT_TO_HOMEPAGE === $this->actionMarkAsRead) { | 32 | $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; |
33 | |||
34 | if (null === $user || !is_object($user)) { | ||
35 | return $url; | ||
36 | } | ||
37 | |||
38 | if (Config::REDIRECT_TO_HOMEPAGE === $user->getConfig()->getActionMarkAsRead()) { | ||
32 | return $this->router->generate('homepage'); | 39 | return $this->router->generate('homepage'); |
33 | } | 40 | } |
34 | 41 | ||