aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php')
-rw-r--r--src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php
index 367cdfb0..1b5d61ad 100644
--- a/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php
+++ b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php
@@ -6,8 +6,10 @@ use Symfony\Component\HttpFoundation\Session\Session;
6use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; 6use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
7 7
8/** 8/**
9 * Stores the locale of the user in the session after the 9 * Stores the locale of the user in the session after the login.
10 * login. This can be used by the LocaleListener afterwards. 10 * If no locale are defined (if user doesn't change it from the login screen), override it with the user's config one.
11 *
12 * This can be used by the LocaleListener afterwards.
11 * 13 *
12 * @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html 14 * @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html
13 */ 15 */
@@ -23,14 +25,11 @@ class UserLocaleListener
23 $this->session = $session; 25 $this->session = $session;
24 } 26 }
25 27
26 /**
27 * @param InteractiveLoginEvent $event
28 */
29 public function onInteractiveLogin(InteractiveLoginEvent $event) 28 public function onInteractiveLogin(InteractiveLoginEvent $event)
30 { 29 {
31 $user = $event->getAuthenticationToken()->getUser(); 30 $user = $event->getAuthenticationToken()->getUser();
32 31
33 if (null !== $user->getConfig()->getLanguage()) { 32 if (null !== $user->getConfig()->getLanguage() && null === $this->session->get('_locale')) {
34 $this->session->set('_locale', $user->getConfig()->getLanguage()); 33 $this->session->set('_locale', $user->getConfig()->getLanguage());
35 } 34 }
36 } 35 }