<?php
namespace App\EventListener;
use App\Utils\CurrentLocaleUtil;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class ControllerListener implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
KernelEvents::CONTROLLER => ["onKernelController", 999]
];
}
public function onKernelController(ControllerEvent $event) {
$request = $event->getRequest();
CurrentLocaleUtil::setLocale($request->getLocale());
}
}