src/EventSubscriber/AdminSyncProfilerSubscriber.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. use Symfony\Component\HttpKernel\KernelEvents;
  6. use Symfony\Component\HttpKernel\Profiler\Profiler;
  7. class AdminSyncProfilerSubscriber implements EventSubscriberInterface
  8. {
  9.     private $profiler;
  10.     public function __construct(?Profiler $profiler null)
  11.     {
  12.         $this->profiler $profiler;
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [
  17.             KernelEvents::REQUEST => ['disableProfilerForAdminSync'255],
  18.         ];
  19.     }
  20.     public function disableProfilerForAdminSync(RequestEvent $event): void
  21.     {
  22.         if (!$event->isMasterRequest() || $this->profiler === null) {
  23.             return;
  24.         }
  25.         if (strpos($event->getRequest()->getPathInfo(), '/admin/sync/') === 0) {
  26.             $this->profiler->disable();
  27.         }
  28.     }
  29. }