aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2016-11-07 10:26:05 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-11-16 23:07:34 +0100
commit65cd8a4a9a1d15d962033f58276005a5f7716f3a (patch)
treec0dd762b631ae22443fb5efba3b838aeee01f7af /src
parentf052f1fd57e51c8ae5ac17587636d608619a2057 (diff)
downloadwallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.gz
wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.tar.zst
wallabag-65cd8a4a9a1d15d962033f58276005a5f7716f3a.zip
Added tests
Diffstat (limited to 'src')
-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