<?php
namespace App\EventSubscriber;
use App\Service\UtmCatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class UtmSubscriber implements EventSubscriberInterface
{
/**
* @var UtmCatcher
*/
private $utmCatcher;
public function __construct(UtmCatcher $utmCatcher)
{
$this->utmCatcher = $utmCatcher;
}
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['onKernelRequest', 110],
];
}
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMainRequest()) {
return;
}
$this->utmCatcher->fromRequest(
$event->getRequest()
);
}
}