Added constants for redirection values

This commit is contained in:
Nicolas Lœuillet 2016-11-07 09:30:37 +01:00 committed by Jeremy Benoist
parent 287204cda7
commit f052f1fd57
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
3 changed files with 8 additions and 3 deletions

View file

@ -16,6 +16,9 @@ use Wallabag\UserBundle\Entity\User;
*/
class Config
{
const REDIRECT_TO_HOMEPAGE = 0;
const REDIRECT_TO_CURRENT_PAGE = 1;
/**
* @var int
*

View file

@ -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, [

View file

@ -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');
}