1 | <?php |
||
27 | final class UserLocaleSubscriber implements EventSubscriberInterface |
||
28 | { |
||
29 | /** |
||
30 | * @var SessionInterface |
||
31 | */ |
||
32 | private $session; |
||
33 | |||
34 | public function __construct(SessionInterface $session) |
||
38 | |||
39 | public function onInteractiveLogin(InteractiveLoginEvent $event): void |
||
40 | { |
||
41 | $user = $event->getAuthenticationToken()->getUser(); |
||
42 | |||
43 | if (\is_callable([$user, 'getLocale']) && null !== $user->getLocale()) { |
||
44 | $this->session->set('_locale', $user->getLocale()); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return array |
||
50 | */ |
||
51 | public static function getSubscribedEvents() |
||
57 | } |
||
58 |