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:
parent
a4b3d8a5f1
commit
2c051351a8
@@ -7,8 +7,6 @@ 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;
|
||||
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;
|
||||
|
||||
@@ -33,18 +31,8 @@ readonly class DeleteCbzHandler implements CommandHandlerInterface
|
||||
throw new CbzFileNotFoundException($command->chapterId);
|
||||
}
|
||||
|
||||
$updatedChapter = new Chapter(
|
||||
new ChapterId($chapter->getId()),
|
||||
$chapter->getMangaId(),
|
||||
$chapter->getNumber(),
|
||||
$chapter->getTitle(),
|
||||
$chapter->getVolume(),
|
||||
$chapter->isVisible(),
|
||||
null,
|
||||
0,
|
||||
$chapter->getCreatedAt()
|
||||
);
|
||||
|
||||
$this->mangaRepository->updateChapter($updatedChapter);
|
||||
$manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue());
|
||||
$manga->removeChapterPages($chapter);
|
||||
$this->mangaRepository->save($manga);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user