Added a configuration to define the redirection after archiving an entry

Fix #496
This commit is contained in:
Nicolas Lœuillet
2016-11-06 12:02:39 +01:00
committed by Jeremy Benoist
parent e042a5d78f
commit a42f38d9fb
26 changed files with 184 additions and 3 deletions

View 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;
}