<?php
namespace App\EventListener;
use App\Controller\Application\SupplierRequest\Event\SupplierRequestEvent;
use App\Message\SupplierRequest\SupplierRequestMessage;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class SupplierRequestEventSubscriber implements EventSubscriberInterface
{
public function __construct(private MessageBusInterface $messageBus)
{
}
public static function getSubscribedEvents()
{
return [
SupplierRequestEvent::CREATE_SUPPLIER_REQUEST_EVENT_NAME => 'onNewSupplierRequest',
];
}
public function onNewSupplierRequest(SupplierRequestEvent $event): void
{
$this->messageBus->dispatch(
new SupplierRequestMessage($event->getSupplerRequest()->getId())
);
}
}