src/System/Listener/Income/IncomeListener.php line 24

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\System\Listener\Income;
  4. use App\System\Infrastructure\Implementation\Connection\Live\Event\Income\CreatedEvent;
  5. use App\UseCase\Income\Event\IncomeCreatedEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Messenger\MessageBusInterface;
  8. class IncomeListener implements EventSubscriberInterface
  9. {
  10.     public function __construct(
  11.         private readonly MessageBusInterface $bus,
  12.     ) {
  13.     }
  14.     public static function getSubscribedEvents(): array
  15.     {
  16.         return [IncomeCreatedEvent::class => 'created'];
  17.     }
  18.     public function created(IncomeCreatedEvent $event): void
  19.     {
  20.         $this->bus->dispatch(
  21.             new CreatedEvent($event->income->getId()),
  22.         );
  23.     }
  24. }