src/App/EventListener/SupplierRequestEventSubscriber.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use App\Controller\Application\SupplierRequest\Event\SupplierRequestEvent;
  4. use App\Message\SupplierRequest\SupplierRequestMessage;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\Messenger\MessageBusInterface;
  7. class SupplierRequestEventSubscriber implements EventSubscriberInterface
  8. {
  9.     public function __construct(private MessageBusInterface $messageBus)
  10.     {
  11.     }
  12.     public static function getSubscribedEvents()
  13.     {
  14.         return [
  15.             SupplierRequestEvent::CREATE_SUPPLIER_REQUEST_EVENT_NAME => 'onNewSupplierRequest',
  16.         ];
  17.     }
  18.     public function onNewSupplierRequest(SupplierRequestEvent $event): void
  19.     {
  20.         $this->messageBus->dispatch(
  21.             new SupplierRequestMessage($event->getSupplerRequest()->getId())
  22.         );
  23.     }
  24. }