refactor(manga): merge ChapterRepositoryInterface into MangaRepositoryInterface + pagesDirectory
- 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>
This commit is contained in:
parent
dae215dd3d
commit
c50f1638ee
@@ -3,7 +3,7 @@
|
||||
namespace App\Domain\Manga\Application\CommandHandler;
|
||||
|
||||
use App\Domain\Manga\Application\Command\DeleteCbz;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||
use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface;
|
||||
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
|
||||
use App\Domain\Manga\Domain\Exception\CbzFileNotFoundException;
|
||||
@@ -15,7 +15,7 @@ use App\Domain\Shared\Domain\Contract\CommandInterface;
|
||||
readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
{
|
||||
public function __construct(
|
||||
private ChapterRepositoryInterface $chapterRepository,
|
||||
private MangaRepositoryInterface $mangaRepository,
|
||||
private FileServiceInterface $fileService
|
||||
) {}
|
||||
|
||||
@@ -23,22 +23,16 @@ readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
{
|
||||
assert($command instanceof DeleteCbz);
|
||||
|
||||
$chapter = $this->chapterRepository->findVisibleById($command->chapterId);
|
||||
$chapter = $this->mangaRepository->findVisibleChapterById($command->chapterId);
|
||||
|
||||
if (!$chapter) {
|
||||
throw new ChapterNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
// Check if chapter has a CBZ file
|
||||
if (!$chapter->isAvailable()) {
|
||||
throw new CbzFileNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
// Delete the physical CBZ file
|
||||
// Note: We'll need to get the CBZ path from somewhere, likely from a legacy repository
|
||||
// For now, we'll just mark the chapter as not available
|
||||
|
||||
// Update chapter to mark CBZ as not available
|
||||
$updatedChapter = new Chapter(
|
||||
new ChapterId($chapter->getId()),
|
||||
$chapter->getMangaId(),
|
||||
@@ -47,9 +41,10 @@ readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
$chapter->getVolume(),
|
||||
$chapter->isVisible(),
|
||||
null,
|
||||
0,
|
||||
$chapter->getCreatedAt()
|
||||
);
|
||||
|
||||
$this->chapterRepository->save($updatedChapter);
|
||||
$this->mangaRepository->updateChapter($updatedChapter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user