Skip to content

Commit

Permalink
fix deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
addfs committed Oct 18, 2022
1 parent 0b7c215 commit d9e7627
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions EventListener/ScriptNameConfigureListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Intaro\PinbaBundle\EventListener;

use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\KernelEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
Expand All @@ -11,11 +10,11 @@ class ScriptNameConfigureListener
{
public function onRequest(KernelEvent $event): void
{
if (!($event instanceof GetResponseEvent || $event instanceof RequestEvent)) {
if (self::bcEvent($event) || !$event instanceof RequestEvent) {
throw new \InvalidArgumentException('Event must be GetResponseEvent or RequestEvent');
}

if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
if (HttpKernelInterface::MAIN_REQUEST !== $event->getRequestType()) {
return;
}

Expand All @@ -25,4 +24,11 @@ public function onRequest(KernelEvent $event): void

pinba_script_name_set($event->getRequest()->getRequestUri());
}

private static function bcEvent($event)
{
$eventClass = \Symfony\Component\HttpKernel\Event\GetResponseEvent::class;

return class_exists($eventClass) && !$event instanceof $eventClass;
}
}

0 comments on commit d9e7627

Please sign in to comment.