src/EventSubscriber/UtmSubscriber.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Service\UtmCatcher;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\RequestEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class UtmSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var UtmCatcher
  11.      */
  12.     private $utmCatcher;
  13.     public function __construct(UtmCatcher $utmCatcher)
  14.     {
  15.         $this->utmCatcher $utmCatcher;
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             KernelEvents::REQUEST => ['onKernelRequest'110],
  21.         ];
  22.     }
  23.     public function onKernelRequest(RequestEvent $event)
  24.     {
  25.         if (!$event->isMainRequest()) {
  26.             return;
  27.         }
  28.         $this->utmCatcher->fromRequest(
  29.             $event->getRequest()
  30.         );
  31.     }
  32. }