<?php
namespace App\Subscriber;
use App\Service\MailerService;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
class FailedMessageSubscriber implements EventSubscriberInterface
{
public function __construct(private readonly MailerService $email)
{
}
public static function getSubscribedEvents(): array
{
return [
WorkerMessageFailedEvent::class => 'onMessageFailed'
];
}
public function onMessageFailed(WorkerMessageFailedEvent $event)
{
$message = $event->getEnvelope()->getMessage()::class;
$this->email->failedEncodeVideo('Problème sur l\'encodage d\'une vidéo');
}
}