src/EventSubscriber/Hermes/ExceptionSubscriber.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber\Hermes;
  3. use App\Service\Hermes\NotificationService;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. use Symfony\Component\HttpKernel\Event\ExceptionEvent;
  6. class ExceptionSubscriber implements EventSubscriberInterface
  7. {
  8.     private NotificationService $notificationService;
  9.     /**
  10.      * ExceptionSubscriber constructor.
  11.      * @param NotificationService $notificationService
  12.      */
  13.     public function __construct(NotificationService $notificationService)
  14.     {
  15.         $this->notificationService $notificationService;
  16.     }
  17.     public function onKernelException(ExceptionEvent $event)
  18.     {
  19.         $this->notificationService->createNotification($event->getThrowable());
  20.     }
  21.     public static function getSubscribedEvents()
  22.     {
  23.         return [
  24.             'kernel.exception' => 'onKernelException',
  25.         ];
  26.     }
  27. }