for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;
/**
* Stores the locale of the user in the session after the
* login. This can be used by the LocaleSubscriber afterwards.
*
* Priority order: platform -> user
* Priority order: platform -> user -> course
*/
class UserLocaleSubscriber implements EventSubscriberInterface
{
private $session;
public function __construct(SessionInterface $session)
$this->session = $session;
}
* Set locale when user enters the platform.
public function onInteractiveLogin(InteractiveLoginEvent $event)
$user = $event->getAuthenticationToken()->getUser();
if (null !== $user->getLocale()) {
$this->session->set('_locale', $user->getLocale());
$this->session->set('_locale_user', $user->getLocale());
public static function getSubscribedEvents()
return [
SecurityEvents::INTERACTIVE_LOGIN => 'onInteractiveLogin',
];