- Supprime ChapterRepositoryInterface du domaine Manga (et ses implémentations LegacyChapterRepository et InMemoryChapterRepository) - Déplace toutes les méthodes chapter vers MangaRepositoryInterface avec nommage explicite (findChapterById, findVisibleChapterById, updateChapter, deleteChapter, etc.) - Remplace cbzPath par pagesDirectory + pageCount dans le modèle Chapter (transition : toChapterDomain conserve un fallback cbzPath pour les données existantes, updateChapter synchronise les deux colonnes jusqu'à la Phase 4) - Ajoute la migration Doctrine (pages_directory, page_count sur la table chapter) - Met à jour tous les handlers, listeners, query handlers et state providers du domaine Manga pour injecter uniquement MangaRepositoryInterface - Adapte les tests unitaires et InMemoryMangaRepository avec les nouvelles méthodes Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.5 KiB
PHP
44 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Manga\Application\CommandHandler;
|
|
|
|
use App\Domain\Manga\Application\Command\DeleteChapter;
|
|
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
|
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
|
use App\Domain\Manga\Domain\Model\Chapter;
|
|
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
|
|
use App\Domain\Shared\Domain\Contract\CommandHandlerInterface;
|
|
use App\Domain\Shared\Domain\Contract\CommandInterface;
|
|
|
|
readonly class DeleteChapterHandler implements CommandHandlerInterface
|
|
{
|
|
public function __construct(
|
|
private MangaRepositoryInterface $mangaRepository
|
|
) {}
|
|
|
|
public function handle(CommandInterface $command): void
|
|
{
|
|
assert($command instanceof DeleteChapter);
|
|
|
|
$chapter = $this->mangaRepository->findVisibleChapterById($command->chapterId);
|
|
|
|
if (!$chapter) {
|
|
throw new ChapterNotFoundException($command->chapterId);
|
|
}
|
|
|
|
$updatedChapter = new Chapter(
|
|
id: new ChapterId($chapter->getId()),
|
|
mangaId: $chapter->getMangaId(),
|
|
number: $chapter->getNumber(),
|
|
title: $chapter->getTitle(),
|
|
volume: $chapter->getVolume(),
|
|
isVisible: false,
|
|
pagesDirectory: $chapter->getPagesDirectory(),
|
|
pageCount: $chapter->getPageCount(),
|
|
createdAt: $chapter->getCreatedAt()
|
|
);
|
|
|
|
$this->mangaRepository->updateChapter($updatedChapter);
|
|
}
|
|
}
|