From be417ef23685e17a239b1d192a0e9b9f484f1bfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 12 Jun 2017 17:23:35 +0200 Subject: Added possibility to change locale from login/register pages --- src/Wallabag/UserBundle/EventListener/CreateConfigListener.php | 7 +++++-- src/Wallabag/UserBundle/Resources/config/services.yml | 1 + .../Resources/views/Registration/register_content.html.twig | 1 - src/Wallabag/UserBundle/Resources/views/layout.html.twig | 5 +++++ 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/Wallabag/UserBundle') diff --git a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php index e4d55c19..5cabfd35 100644 --- a/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php +++ b/src/Wallabag/UserBundle/EventListener/CreateConfigListener.php @@ -6,6 +6,7 @@ use Doctrine\ORM\EntityManager; use FOS\UserBundle\Event\UserEvent; use FOS\UserBundle\FOSUserEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpFoundation\Session\Session; use Wallabag\CoreBundle\Entity\Config; /** @@ -22,8 +23,9 @@ class CreateConfigListener implements EventSubscriberInterface private $readingSpeed; private $actionMarkAsRead; private $listMode; + private $session; - public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode) + public function __construct(EntityManager $em, $theme, $itemsOnPage, $rssLimit, $language, $readingSpeed, $actionMarkAsRead, $listMode, Session $session) { $this->em = $em; $this->theme = $theme; @@ -33,6 +35,7 @@ class CreateConfigListener implements EventSubscriberInterface $this->readingSpeed = $readingSpeed; $this->actionMarkAsRead = $actionMarkAsRead; $this->listMode = $listMode; + $this->session = $session; } public static function getSubscribedEvents() @@ -52,7 +55,7 @@ class CreateConfigListener implements EventSubscriberInterface $config->setTheme($this->theme); $config->setItemsPerPage($this->itemsOnPage); $config->setRssLimit($this->rssLimit); - $config->setLanguage($this->language); + $config->setLanguage($this->session->get('_locale', $this->language)); $config->setReadingSpeed($this->readingSpeed); $config->setActionMarkAsRead($this->actionMarkAsRead); $config->setListMode($this->listMode); diff --git a/src/Wallabag/UserBundle/Resources/config/services.yml b/src/Wallabag/UserBundle/Resources/config/services.yml index d3925de3..72cda3f8 100644 --- a/src/Wallabag/UserBundle/Resources/config/services.yml +++ b/src/Wallabag/UserBundle/Resources/config/services.yml @@ -33,6 +33,7 @@ services: - "%wallabag_core.reading_speed%" - "%wallabag_core.action_mark_as_read%" - "%wallabag_core.list_mode%" + - "@session" tags: - { name: kernel.event_subscriber } diff --git a/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig b/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig index d0a85fc7..85cd4f0d 100644 --- a/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Registration/register_content.html.twig @@ -3,7 +3,6 @@ {{ form_start(form, {'method': 'post', 'action': path('fos_user_registration_register'), 'attr': {'class': 'fos_user_registration_register'}}) }}
- {{ form_widget(form._token) }} {% for flashMessage in app.session.flashbag.get('notice') %} diff --git a/src/Wallabag/UserBundle/Resources/views/layout.html.twig b/src/Wallabag/UserBundle/Resources/views/layout.html.twig index 99bf7dfd..6934c686 100644 --- a/src/Wallabag/UserBundle/Resources/views/layout.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/layout.html.twig @@ -15,6 +15,11 @@ {% block fos_user_content %} {% endblock fos_user_content %}
+
{% endblock %} -- cgit v1.2.3