]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/EventListener/UserLocaleListener.php
Language selection on config screen
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / EventListener / UserLocaleListener.php
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 }