aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-10-18 15:35:42 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-10-18 15:35:42 +0200
commitfcc6949d4a70f8b1d2c2b4e2c1e2fabdf6a93a7c (patch)
treecc09f37927d4a7ffbf576f636db0d36015190b08 /src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
parent3d3ed955f11006a408c6596eb9151a0afb28e721 (diff)
parent2aac2f278f1ca63f2097f80ddbdb924dea9ec59e (diff)
downloadwallabag-fcc6949d4a70f8b1d2c2b4e2c1e2fabdf6a93a7c.tar.gz
wallabag-fcc6949d4a70f8b1d2c2b4e2c1e2fabdf6a93a7c.tar.zst
wallabag-fcc6949d4a70f8b1d2c2b4e2c1e2fabdf6a93a7c.zip
Merge pull request #1446 from wallabag/v2-language-config
[WIP] language selection on config screen
Diffstat (limited to 'src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php')
-rw-r--r--src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php b/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
new file mode 100644
index 00000000..82d1a63a
--- /dev/null
+++ b/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
@@ -0,0 +1,37 @@
1<?php
2
3namespace Wallabag\CoreBundle\EventListener;
4
5use Symfony\Component\HttpFoundation\Session\Session;
6use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
7
8/**
9 * Stores the locale of the user in the session after the
10 * login. This can be used by the LocaleListener afterwards.
11 *
12 * @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html
13 */
14class UserLocaleListener
15{
16 /**
17 * @var Session
18 */
19 private $session;
20
21 public function __construct(Session $session)
22 {
23 $this->session = $session;
24 }
25
26 /**
27 * @param InteractiveLoginEvent $event
28 */
29 public function onInteractiveLogin(InteractiveLoginEvent $event)
30 {
31 $user = $event->getAuthenticationToken()->getUser();
32
33 if (null !== $user->getConfig()->getLanguage()) {
34 $this->session->set('_locale', $user->getConfig()->getLanguage());
35 }
36 }
37}