src/EventListener/ControllerListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Utils\CurrentLocaleUtil;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class ControllerListener implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             KernelEvents::CONTROLLER => ["onKernelController"999]
  13.         ];
  14.     }
  15.     public function onKernelController(ControllerEvent $event) {
  16.         $request $event->getRequest();
  17.         CurrentLocaleUtil::setLocale($request->getLocale());
  18.     }
  19. }