]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/Redirect.php
Added a configuration to define the redirection after archiving an entry
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / Redirect.php
index c14c79d11bd1f6a46312160174c177ae0fca3e14..918d926616a517fa26b2e1d9c02cdcad709cf3a7 100644 (file)
@@ -3,6 +3,7 @@
 namespace Wallabag\CoreBundle\Helper;
 
 use Symfony\Component\Routing\Router;
+use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
 
 /**
  * Manage redirections to avoid redirecting to empty routes.
@@ -10,10 +11,12 @@ use Symfony\Component\Routing\Router;
 class Redirect
 {
     private $router;
+    private $actionMarkAsRead;
 
-    public function __construct(Router $router)
+    public function __construct(Router $router, TokenStorage $token)
     {
         $this->router = $router;
+        $this->actionMarkAsRead = $token->getToken()->getUser()->getConfig()->getActionMarkAsRead();
     }
 
     /**
@@ -24,6 +27,10 @@ class Redirect
      */
     public function to($url, $fallback = '')
     {
+        if ($this->actionMarkAsRead == 0) {
+            return $this->router->generate('homepage');
+        }
+
         if (null !== $url) {
             return $url;
         }