diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-10-01 16:28:38 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2015-10-15 21:42:29 +0200 |
commit | c89d35e851d26b78f89bd7ece5e3eaa109c8cac0 (patch) | |
tree | 554523b6b376d258fbf82b8ef8ec16236f774b5f /src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php | |
parent | 3d3ed955f11006a408c6596eb9151a0afb28e721 (diff) | |
download | wallabag-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.php | 35 |
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 | |||
3 | namespace Wallabag\CoreBundle\EventListener; | ||
4 | |||
5 | use Symfony\Component\HttpFoundation\Session\Session; | ||
6 | use 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 | class 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 | } | ||