<?php
declare(strict_types=1);
namespace App\System\Listener\Income;
use App\System\Infrastructure\Implementation\Connection\Live\Event\Income\CreatedEvent;
use App\UseCase\Income\Event\IncomeCreatedEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Messenger\MessageBusInterface;
class IncomeListener implements EventSubscriberInterface
{
public function __construct(
private readonly MessageBusInterface $bus,
) {
}
public static function getSubscribedEvents(): array
{
return [IncomeCreatedEvent::class => 'created'];
}
public function created(IncomeCreatedEvent $event): void
{
$this->bus->dispatch(
new CreatedEvent($event->income->getId()),
);
}
}