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 ); } }