<?php
namespace App\EventSubscriber\Hermes;
use App\Service\Hermes\NotificationService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
class ExceptionSubscriber implements EventSubscriberInterface
{
private NotificationService $notificationService;
/**
* ExceptionSubscriber constructor.
* @param NotificationService $notificationService
*/
public function __construct(NotificationService $notificationService)
{
$this->notificationService = $notificationService;
}
public function onKernelException(ExceptionEvent $event)
{
$this->notificationService->createNotification($event->getThrowable());
}
public static function getSubscribedEvents()
{
return [
'kernel.exception' => 'onKernelException',
];
}
}