src/EventSubscriber/KernelControllerSubscriber.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\KernelEvents;
  5. use Symfony\Component\HttpKernel\Event\ControllerEvent;
  6. use App\Service\RequestService;
  7. class KernelControllerSubscriber implements EventSubscriberInterface
  8. {
  9.     public function __construct(
  10.         RequestService $requestService
  11.     ) {
  12.         $this->requestService $requestService;
  13.     }
  14.     public static function getSubscribedEvents()
  15.     {
  16.         return [
  17.             KernelEvents::CONTROLLER => 'onKernelController',
  18.         ];
  19.     }
  20.     public function onKernelController(ControllerEvent $event)
  21.     {
  22.         if (!is_array($controllers $event->getController())) {
  23.             return;
  24.         }
  25.         list($controller$methodName) = $controllers;
  26.         // timezone
  27.         $this->requestService->getTimezone($controller);
  28.         // cache
  29.         $this->requestService->startCache($methodName$controller);
  30.         // permission
  31.         $this->requestService->checkPermission($methodName$controller);
  32.         // log
  33.         $this->requestService->startLogging($methodName$controller);
  34.         // set tracking code
  35.         $this->requestService->setTrackingCode();
  36.         // locale
  37.         $this->requestService->setLocale($methodName$controller);
  38.     }
  39. }