Skip to content

Commit

Permalink
Check for existence of isMainRequest or isMasterRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandoorn committed Aug 16, 2023
1 parent 0ae1052 commit 791dc2a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/EventListener/AddRouteListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down
12 changes: 10 additions & 2 deletions src/EventListener/EnvironmentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 791dc2a

Please sign in to comment.