diff --git a/src/EventListener/AddRouteListener.php b/src/EventListener/AddRouteListener.php index 68a3fd4..cfdb307 100644 --- a/src/EventListener/AddRouteListener.php +++ b/src/EventListener/AddRouteListener.php @@ -18,8 +18,16 @@ public function __construct(GoogleTagManagerInterface $googleTagManager) public function onKernelRequest(RequestEvent $event): void { - if (!$event->isMainRequest()) { - return; + if (method_exists($event, 'isMainRequest')) { + if (!$event->isMainRequest()) { + return; + } + } + + if (method_exists($event, 'isMasterRequest')) { + if (!$event->isMasterRequest()) { + return; + } } $this->googleTagManager->setData('route', $event->getRequest()->get('_route')); diff --git a/src/EventListener/ContextListener.php b/src/EventListener/ContextListener.php index 0079a55..f2a42fa 100644 --- a/src/EventListener/ContextListener.php +++ b/src/EventListener/ContextListener.php @@ -35,8 +35,16 @@ public function __construct( public function onKernelRequest(RequestEvent $event): void { - if (!$event->isMainRequest()) { - return; + if (method_exists($event, 'isMainRequest')) { + if (!$event->isMainRequest()) { + return; + } + } + + if (method_exists($event, 'isMasterRequest')) { + if (!$event->isMasterRequest()) { + return; + } } try { diff --git a/src/EventListener/EnvironmentListener.php b/src/EventListener/EnvironmentListener.php index 010baf5..0aacf68 100644 --- a/src/EventListener/EnvironmentListener.php +++ b/src/EventListener/EnvironmentListener.php @@ -21,8 +21,16 @@ public function __construct(GoogleTagManagerInterface $googleTagManager, string public function onKernelRequest(RequestEvent $event): void { - if (!$event->isMainRequest()) { - return; + if (method_exists($event, 'isMainRequest')) { + if (!$event->isMainRequest()) { + return; + } + } + + if (method_exists($event, 'isMasterRequest')) { + if (!$event->isMasterRequest()) { + return; + } } $this->googleTagManager->setData('env', $this->environment);