feat: refonte de la gestion des événements de création de mangas en remplaçant le MessageBus par un EventDispatcher. Ajout d'un écouteur d'événements MangaCreated pour gérer la récupération des chapitres après la création d'un manga. Implémentation d'un EventDispatcher basé sur Symfony Messenger.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-07-31 16:11:16 +02:00
parent f1eb97f156
commit bec1572fcb
5 changed files with 53 additions and 8 deletions

View File

@@ -1,22 +0,0 @@
<?php
namespace App\Domain\Manga\Infrastructure\EventListener;
use App\Domain\Manga\Application\Command\FetchMangaChapters;
use App\Domain\Manga\Domain\Event\MangaCreated;
use App\Domain\Manga\Domain\Model\ValueObject\MangaId;
use Symfony\Component\Messenger\MessageBusInterface;
readonly class MangaCreatedListener
{
public function __construct(
private MessageBusInterface $messageBus
) {}
public function __invoke(MangaCreated $event): void
{
$this->messageBus->dispatch(
new FetchMangaChapters(new MangaId($event->mangaId))
);
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace App\Domain\Manga\Infrastructure\MessageHandler;
use App\Domain\Manga\Application\EventListener\MangaCreatedEventListener;
use App\Domain\Manga\Domain\Event\MangaCreated;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
readonly class MangaCreatedMessageHandler
{
public function __construct(private MangaCreatedEventListener $listener)
{
}
public function __invoke(MangaCreated $event): void
{
$this->listener->__invoke($event);
}
}