src/Core/EventSubscriber/UserLocaleSubscriber.php line 28
<?phpnamespace App\Core\EventSubscriber;use JetBrains\PhpStorm\ArrayShape;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpFoundation\RequestStack;use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;use Symfony\Component\Security\Http\SecurityEvents;class UserLocaleSubscriber implements EventSubscriberInterface{private RequestStack $requestStack;public function __construct(RequestStack $requestStack){$this->requestStack = $requestStack;}#[ArrayShape([SecurityEvents::INTERACTIVE_LOGIN => 'string'])]public static function getSubscribedEvents(): array{return [SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',];}public function onInteractiveLogin(InteractiveLoginEvent $loginEvent){$user = $loginEvent->getAuthenticationToken()->getUser();if (null !== $user->getLocale()) {$this->requestStack->getSession()->set('_locale', $user->getLocale());}}}