src/EventSubscriber/ApplicationConfigurationSubscriber.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use App\Event\CreateApplicationConfigurationEvent;
  4. use App\Message\CreateApplicationConfigurationMessage;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Symfony\Component\Messenger\MessageBusInterface;
  7. class ApplicationConfigurationSubscriber implements EventSubscriberInterface
  8. {
  9.     protected MessageBusInterface $bus;
  10.     /**
  11.      * @param MessageBusInterface $bus
  12.      */
  13.     public function __construct(MessageBusInterface $bus)
  14.     {
  15.         $this->bus $bus;
  16.     }
  17.     public static function getSubscribedEvents(): array
  18.     {
  19.         return [
  20.             CreateApplicationConfigurationEvent::NAME => 'onCreateApplicationConfiguration',
  21.         ];
  22.     }
  23.     public function onCreateApplicationConfiguration(CreateApplicationConfigurationEvent $event): void
  24.     {
  25.         $payload = [
  26.             'applicationConfiguration' => $event->getApplicationConfiguration(),
  27.         ];
  28.         $message = new CreateApplicationConfigurationMessage($payload);
  29.         $this->bus->dispatch($message);
  30.     }
  31. }