refactor(manga): Chapter entité DDD de Manga + AggregateRoot

- Ajoute AggregateRoot dans Shared (domain events + pull pattern)
- Manga extends AggregateRoot, devient vrai aggregate root DDD
- Chapter passe de readonly à entité mutable avec MangaId VO
- Manga expose les méthodes domaine pour toute mutation de chapitre :
  addChapter, updateChapterTitle/Volume/Pages, hideChapter, removeChapterPages
- Supprime saveChapter/updateChapter/deleteChapter de MangaRepositoryInterface
- save(Manga) gère désormais la persistance des chapitres via pull pattern
- Tous les handlers/listeners passent par l'agrégat (plus d'accès direct)
- phparkitect autorise AggregateRoot dans les couches Domain

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-09 19:15:11 +01:00
parent a4b3d8a5f1
commit 2c051351a8
18 changed files with 226 additions and 255 deletions

View File

@@ -76,19 +76,18 @@ class ImportChapterHandlerTest extends TestCase
['action', 'adventure'],
'ongoing'
);
$this->mangaRepository->save($manga);
// Create an existing chapter without pages
// Create an existing chapter without pages and add through the aggregate
$existingChapter = new Chapter(
new ChapterId('chapter-123'),
$mangaId,
new MangaId($mangaId),
1.5,
'Chapter 1.5',
1,
true,
null
);
$this->mangaRepository->saveChapter($existingChapter);
$manga->addChapter($existingChapter);
$this->mangaRepository->save($manga);
// Import the same chapter with CBZ
$cbzBinary = $this->createValidCbzBinary();
@@ -105,7 +104,7 @@ class ImportChapterHandlerTest extends TestCase
$updatedChapter = $this->mangaRepository->findChapterById('chapter-123');
$this->assertNotNull($updatedChapter);
$this->assertEquals('chapter-123', $updatedChapter->getId());
$this->assertEquals($mangaId, $updatedChapter->getMangaId());
$this->assertEquals($mangaId, $updatedChapter->getMangaId()->getValue());
$this->assertEquals(1.5, $updatedChapter->getNumber());
$this->assertEquals('Chapter 1.5', $updatedChapter->getTitle());
$this->assertEquals(1, $updatedChapter->getVolume());