From 6ea24deacfb7c6e0ad33365ecfdcf845b6b27974 Mon Sep 17 00:00:00 2001 From: "ext.jeremy.guillot@maxicoffee.domains" Date: Thu, 27 Mar 2025 11:15:36 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20ajout=20de=20la=20gestion=20de=20la=20d?= =?UTF-8?q?isponibilit=C3=A9=20des=20chapitres=20dans=20les=20r=C3=A9ponse?= =?UTF-8?q?s=20et=20les=20mod=C3=A8les,=20avec=20mise=20=C3=A0=20jour=20de?= =?UTF-8?q?s=20classes=20concern=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../QueryHandler/GetMangaChaptersHandler.php | 5 +++-- .../Manga/Application/Response/ChapterResponse.php | 1 + src/Domain/Manga/Domain/Model/Chapter.php | 8 +++++++- .../ApiPlatform/Dto/ChapterListItem.php | 1 + .../Provider/GetMangaChaptersStateProvider.php | 1 + .../Persistence/LegacyMangaRepository.php | 14 +++++++------- 6 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/Domain/Manga/Application/QueryHandler/GetMangaChaptersHandler.php b/src/Domain/Manga/Application/QueryHandler/GetMangaChaptersHandler.php index cbec533..f15f7fe 100644 --- a/src/Domain/Manga/Application/QueryHandler/GetMangaChaptersHandler.php +++ b/src/Domain/Manga/Application/QueryHandler/GetMangaChaptersHandler.php @@ -7,7 +7,7 @@ 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( @@ -32,12 +32,13 @@ readonly class GetMangaChaptersHandler return new ChapterListResponse( chapters: array_map( - fn ($chapter) => new ChapterResponse( + fn (Chapter $chapter) => new ChapterResponse( id: $chapter->getId(), number: $chapter->getNumber(), title: $chapter->getTitle(), volume: $chapter->getVolume(), isVisible: $chapter->isVisible(), + isAvailable: $chapter->isAvailable(), createdAt: $chapter->getCreatedAt() ), $chapters diff --git a/src/Domain/Manga/Application/Response/ChapterResponse.php b/src/Domain/Manga/Application/Response/ChapterResponse.php index 7ced7e9..02a5257 100644 --- a/src/Domain/Manga/Application/Response/ChapterResponse.php +++ b/src/Domain/Manga/Application/Response/ChapterResponse.php @@ -10,6 +10,7 @@ readonly class ChapterResponse public ?string $title, public ?int $volume, public bool $isVisible, + public bool $isAvailable, public \DateTimeImmutable $createdAt ) {} } \ No newline at end of file diff --git a/src/Domain/Manga/Domain/Model/Chapter.php b/src/Domain/Manga/Domain/Model/Chapter.php index 2c66820..cb5697e 100644 --- a/src/Domain/Manga/Domain/Model/Chapter.php +++ b/src/Domain/Manga/Domain/Model/Chapter.php @@ -13,7 +13,8 @@ readonly class Chapter private ?string $title, private ?int $volume, private bool $isVisible, - private \DateTimeImmutable $createdAt + private bool $isAvailable = false, + private \DateTimeImmutable $createdAt = new \DateTimeImmutable() ) {} public function getId(): string @@ -46,6 +47,11 @@ readonly class Chapter return $this->isVisible; } + public function isAvailable(): bool + { + return $this->isAvailable; + } + public function getCreatedAt(): \DateTimeImmutable { return $this->createdAt; diff --git a/src/Domain/Manga/Infrastructure/ApiPlatform/Dto/ChapterListItem.php b/src/Domain/Manga/Infrastructure/ApiPlatform/Dto/ChapterListItem.php index d192ffb..0c4cd44 100644 --- a/src/Domain/Manga/Infrastructure/ApiPlatform/Dto/ChapterListItem.php +++ b/src/Domain/Manga/Infrastructure/ApiPlatform/Dto/ChapterListItem.php @@ -13,6 +13,7 @@ readonly class ChapterListItem public ?string $title, public ?int $volume, public bool $isVisible, + public bool $isAvailable, public string $createdAt ) {} } \ No newline at end of file diff --git a/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaChaptersStateProvider.php b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaChaptersStateProvider.php index 08dd8e1..4d6b81b 100644 --- a/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaChaptersStateProvider.php +++ b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/GetMangaChaptersStateProvider.php @@ -52,6 +52,7 @@ readonly class GetMangaChaptersStateProvider implements ProviderInterface title: $chapter->title, volume: $chapter->volume, isVisible: $chapter->isVisible, + isAvailable: $chapter->isAvailable, createdAt: $chapter->createdAt->format(\DateTimeInterface::RFC3339) ); } diff --git a/src/Domain/Manga/Infrastructure/Persistence/LegacyMangaRepository.php b/src/Domain/Manga/Infrastructure/Persistence/LegacyMangaRepository.php index b2d8ce1..69a1b33 100644 --- a/src/Domain/Manga/Infrastructure/Persistence/LegacyMangaRepository.php +++ b/src/Domain/Manga/Infrastructure/Persistence/LegacyMangaRepository.php @@ -222,13 +222,13 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface private function toChapterDomain(EntityChapter $entity): Chapter { return new Chapter( - new ChapterId((string) $entity->getId()), - $entity->getManga()->getId(), - $entity->getNumber(), - $entity->getTitle(), - $entity->getVolume(), - $entity->isVisible(), - new \DateTimeImmutable() + id: new ChapterId((string) $entity->getId()), + mangaId: $entity->getManga()->getId(), + number: $entity->getNumber(), + title: $entity->getTitle(), + volume: $entity->getVolume(), + isVisible: $entity->isVisible(), + isAvailable: $entity->getCbzPath() !== null ); } }