Skip to content

Commit

Permalink
Merge pull request #134 from stefandoorn/main-master-request
Browse files Browse the repository at this point in the history
Check for existence of isMainRequest or isMasterRequest
  • Loading branch information
stefandoorn authored Aug 16, 2023
2 parents 0ae1052 + 6c5b6b0 commit 158f574
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 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/ContextListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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 158f574

Please sign in to comment.