Files
Mangarr/src/Domain/Manga/Application/QueryHandler/GetMangaChaptersHandler.php
ext.jeremy.guillot@maxicoffee.domains c50f1638ee 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>
2026-03-09 17:54:35 +01:00

51 lines
1.7 KiB
PHP

<?php
namespace App\Domain\Manga\Application\QueryHandler;
use App\Domain\Manga\Application\Query\GetMangaChapters;
use App\Domain\Manga\Application\Response\ChapterListResponse;
use App\Domain\Manga\Application\Response\ChapterResponse;
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
use App\Domain\Manga\Domain\Model\Chapter;
readonly class GetMangaChaptersHandler
{
public function __construct(
private MangaRepositoryInterface $mangaRepository
) {}
public function handle(GetMangaChapters $query): ChapterListResponse
{
$manga = $this->mangaRepository->findById($query->mangaId);
if (!$manga) {
throw new MangaNotFoundException();
}
$chapters = $this->mangaRepository->findChapters(
mangaId: $query->mangaId,
page: $query->page,
limit: $query->limit,
sortOrder: $query->sortOrder
);
$total = $this->mangaRepository->countChapters($query->mangaId);
return new ChapterListResponse(
chapters: array_map(
fn (Chapter $chapter) => new ChapterResponse(
id: $chapter->getId(),
number: $chapter->getNumber(),
title: $chapter->getTitle(),
volume: $chapter->getVolume(),
isVisible: $chapter->isVisible(),
pagesDirectory: $chapter->getPagesDirectory(),
createdAt: $chapter->getCreatedAt()
),
$chapters
),
total: $total,
page: $query->page,
limit: $query->limit
);
}
}