From f052f1fd57e51c8ae5ac17587636d608619a2057 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 7 Nov 2016 09:30:37 +0100 Subject: [PATCH] Added constants for redirection values --- src/Wallabag/CoreBundle/Entity/Config.php | 3 +++ src/Wallabag/CoreBundle/Form/Type/ConfigType.php | 5 +++-- src/Wallabag/CoreBundle/Helper/Redirect.php | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Wallabag/CoreBundle/Entity/Config.php b/src/Wallabag/CoreBundle/Entity/Config.php index c40d1535..bfc2fff8 100644 --- a/src/Wallabag/CoreBundle/Entity/Config.php +++ b/src/Wallabag/CoreBundle/Entity/Config.php @@ -16,6 +16,9 @@ use Wallabag\UserBundle\Entity\User; */ class Config { + const REDIRECT_TO_HOMEPAGE = 0; + const REDIRECT_TO_CURRENT_PAGE = 1; + /** * @var int * diff --git a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php index 3b1a8026..7e3b9dd4 100644 --- a/src/Wallabag/CoreBundle/Form/Type/ConfigType.php +++ b/src/Wallabag/CoreBundle/Form/Type/ConfigType.php @@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Wallabag\CoreBundle\Entity\Config; class ConfigType extends AbstractType { @@ -51,8 +52,8 @@ class ConfigType extends AbstractType ->add('action_mark_as_read', ChoiceType::class, [ 'label' => 'config.form_settings.action_mark_as_read.label', 'choices' => [ - 'config.form_settings.action_mark_as_read.redirect_homepage' => '0', - 'config.form_settings.action_mark_as_read.redirect_current_page' => '1', + 'config.form_settings.action_mark_as_read.redirect_homepage' => Config::REDIRECT_TO_HOMEPAGE, + 'config.form_settings.action_mark_as_read.redirect_current_page' => Config::REDIRECT_TO_CURRENT_PAGE, ], ]) ->add('language', ChoiceType::class, [ diff --git a/src/Wallabag/CoreBundle/Helper/Redirect.php b/src/Wallabag/CoreBundle/Helper/Redirect.php index 918d9266..59172db4 100644 --- a/src/Wallabag/CoreBundle/Helper/Redirect.php +++ b/src/Wallabag/CoreBundle/Helper/Redirect.php @@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Helper; use Symfony\Component\Routing\Router; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; +use Wallabag\CoreBundle\Entity\Config; /** * Manage redirections to avoid redirecting to empty routes. @@ -27,7 +28,7 @@ class Redirect */ public function to($url, $fallback = '') { - if ($this->actionMarkAsRead == 0) { + if (Config::REDIRECT_TO_HOMEPAGE === $this->actionMarkAsRead) { return $this->router->generate('homepage'); } -- 2.41.0