diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-11-03 16:22:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 16:22:07 +0100 |
commit | da4136557963018287cae61226e9006c3c741747 (patch) | |
tree | 6bf23c0d32f3780843798ae47c65377ae1ff961a /src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php | |
parent | 816c0940d142f8ec69bdd3f302c9751033cce7e2 (diff) | |
parent | ca08d02f2f17c0e4ec0152a701c540f62713a428 (diff) | |
download | wallabag-da4136557963018287cae61226e9006c3c741747.tar.gz wallabag-da4136557963018287cae61226e9006c3c741747.tar.zst wallabag-da4136557963018287cae61226e9006c3c741747.zip |
Merge pull request #2180 from wallabag/download-pictures
Download pictures
Diffstat (limited to 'src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php new file mode 100644 index 00000000..367cdfb0 --- /dev/null +++ b/src/Wallabag/CoreBundle/Event/Listener/UserLocaleListener.php | |||
@@ -0,0 +1,37 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Event\Listener; | ||
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 | * @see http://symfony.com/doc/master/cookbook/session/locale_sticky_session.html | ||
13 | */ | ||
14 | class 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 | } | ||