refactor: remplacement du gestionnaire de commandes SymfonySetMangaPreferredSourcesHandler par SetMangaPreferredSourcesHandler pour simplifier le traitement des sources préférées des mangas

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-29 16:19:54 +02:00
parent a00858ae6e
commit 7fe4ac0d3b
2 changed files with 3 additions and 24 deletions

View File

@@ -5,13 +5,13 @@ namespace App\Domain\Scraping\Infrastructure\ApiPlatform\State\Processor;
use ApiPlatform\Metadata\Operation; use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface; use ApiPlatform\State\ProcessorInterface;
use App\Domain\Scraping\Application\Command\SetMangaPreferredSources; use App\Domain\Scraping\Application\Command\SetMangaPreferredSources;
use App\Domain\Scraping\Application\CommandHandler\SetMangaPreferredSourcesHandler;
use App\Domain\Scraping\Infrastructure\ApiPlatform\Resource\SetMangaPreferredSourcesResource; use App\Domain\Scraping\Infrastructure\ApiPlatform\Resource\SetMangaPreferredSourcesResource;
use Symfony\Component\Messenger\MessageBusInterface;
final class SetMangaPreferredSourcesStateProcessor implements ProcessorInterface final class SetMangaPreferredSourcesStateProcessor implements ProcessorInterface
{ {
public function __construct( public function __construct(
private readonly MessageBusInterface $commandBus private readonly SetMangaPreferredSourcesHandler $handler
) { ) {
} }
@@ -26,7 +26,7 @@ final class SetMangaPreferredSourcesStateProcessor implements ProcessorInterface
throw new \InvalidArgumentException('Manga ID is required'); throw new \InvalidArgumentException('Manga ID is required');
} }
$this->commandBus->dispatch( $this->handler->handle(
new SetMangaPreferredSources( new SetMangaPreferredSources(
(string) $mangaId, (string) $mangaId,
$data->sourceIds $data->sourceIds

View File

@@ -1,21 +0,0 @@
<?php
namespace App\Domain\Scraping\Infrastructure\CommandHandler;
use App\Domain\Scraping\Application\Command\SetMangaPreferredSources;
use App\Domain\Scraping\Application\CommandHandler\SetMangaPreferredSourcesHandler;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
#[AsMessageHandler]
class SymfonySetMangaPreferredSourcesHandler
{
public function __construct(
private SetMangaPreferredSourcesHandler $handler
) {
}
public function __invoke(SetMangaPreferredSources $command): void
{
$this->handler->handle($command);
}
}