aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Helper/Redirect.php15
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 @@
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Symfony\Component\Routing\Router; 5use Symfony\Component\Routing\Router;
6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 6use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
7use Wallabag\CoreBundle\Entity\Config; 7use Wallabag\CoreBundle\Entity\Config;
8 8
9/** 9/**
@@ -12,12 +12,13 @@ use Wallabag\CoreBundle\Entity\Config;
12class Redirect 12class 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