aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-10-01 16:28:38 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-10-15 21:42:29 +0200
commitc89d35e851d26b78f89bd7ece5e3eaa109c8cac0 (patch)
tree554523b6b376d258fbf82b8ef8ec16236f774b5f /src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
parent3d3ed955f11006a408c6596eb9151a0afb28e721 (diff)
downloadwallabag-c89d35e851d26b78f89bd7ece5e3eaa109c8cac0.tar.gz
wallabag-c89d35e851d26b78f89bd7ece5e3eaa109c8cac0.tar.zst
wallabag-c89d35e851d26b78f89bd7ece5e3eaa109c8cac0.zip
Language selection on config screen
Diffstat (limited to 'src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php')
-rw-r--r--src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php35
1 files changed, 35 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..97bfabc8
--- /dev/null
+++ b/src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
@@ -0,0 +1,35 @@
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 */
12class UserLocaleListener
13{
14 /**
15 * @var Session
16 */
17 private $session;
18
19 public function __construct(Session $session)
20 {
21 $this->session = $session;
22 }
23
24 /**
25 * @param InteractiveLoginEvent $event
26 */
27 public function onInteractiveLogin(InteractiveLoginEvent $event)
28 {
29 $user = $event->getAuthenticationToken()->getUser();
30
31 if (null !== $user->getConfig()->getLanguage()) {
32 $this->session->set('_locale', $user->getConfig()->getLanguage());
33 }
34 }
35}