- 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>
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Manga\Application\CommandHandler;
|
|
|
|
use App\Domain\Manga\Application\Command\EditMultipleChapters;
|
|
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
|
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
|
|
|
readonly class EditMultipleChaptersHandler
|
|
{
|
|
public function __construct(
|
|
private MangaRepositoryInterface $mangaRepository
|
|
) {}
|
|
|
|
public function handle(EditMultipleChapters $command): void
|
|
{
|
|
foreach ($command->chapters as $chapterData) {
|
|
$chapter = $this->mangaRepository->findChapterById($chapterData->id);
|
|
|
|
if (!$chapter) {
|
|
throw new ChapterNotFoundException($chapterData->id);
|
|
}
|
|
|
|
$updatedChapter = $chapter;
|
|
|
|
if ($chapterData->title !== null) {
|
|
$updatedChapter = $updatedChapter->updateTitle($chapterData->title);
|
|
}
|
|
|
|
if ($chapterData->volume !== null) {
|
|
$updatedChapter = $updatedChapter->updateVolume($chapterData->volume);
|
|
}
|
|
|
|
$this->mangaRepository->updateChapter($updatedChapter);
|
|
}
|
|
}
|
|
}
|