feat: ajout de la gestion de la disponibilité des chapitres dans les réponses et les modèles, avec mise à jour des classes concernées
This commit is contained in:
parent
346fede878
commit
6ea24deacf
@@ -7,7 +7,7 @@ use App\Domain\Manga\Application\Response\ChapterListResponse;
|
|||||||
use App\Domain\Manga\Application\Response\ChapterResponse;
|
use App\Domain\Manga\Application\Response\ChapterResponse;
|
||||||
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
use App\Domain\Manga\Domain\Contract\Repository\MangaRepositoryInterface;
|
||||||
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
use App\Domain\Manga\Domain\Exception\MangaNotFoundException;
|
||||||
|
use App\Domain\Manga\Domain\Model\Chapter;
|
||||||
readonly class GetMangaChaptersHandler
|
readonly class GetMangaChaptersHandler
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
@@ -32,12 +32,13 @@ readonly class GetMangaChaptersHandler
|
|||||||
|
|
||||||
return new ChapterListResponse(
|
return new ChapterListResponse(
|
||||||
chapters: array_map(
|
chapters: array_map(
|
||||||
fn ($chapter) => new ChapterResponse(
|
fn (Chapter $chapter) => new ChapterResponse(
|
||||||
id: $chapter->getId(),
|
id: $chapter->getId(),
|
||||||
number: $chapter->getNumber(),
|
number: $chapter->getNumber(),
|
||||||
title: $chapter->getTitle(),
|
title: $chapter->getTitle(),
|
||||||
volume: $chapter->getVolume(),
|
volume: $chapter->getVolume(),
|
||||||
isVisible: $chapter->isVisible(),
|
isVisible: $chapter->isVisible(),
|
||||||
|
isAvailable: $chapter->isAvailable(),
|
||||||
createdAt: $chapter->getCreatedAt()
|
createdAt: $chapter->getCreatedAt()
|
||||||
),
|
),
|
||||||
$chapters
|
$chapters
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ readonly class ChapterResponse
|
|||||||
public ?string $title,
|
public ?string $title,
|
||||||
public ?int $volume,
|
public ?int $volume,
|
||||||
public bool $isVisible,
|
public bool $isVisible,
|
||||||
|
public bool $isAvailable,
|
||||||
public \DateTimeImmutable $createdAt
|
public \DateTimeImmutable $createdAt
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,8 @@ readonly class Chapter
|
|||||||
private ?string $title,
|
private ?string $title,
|
||||||
private ?int $volume,
|
private ?int $volume,
|
||||||
private bool $isVisible,
|
private bool $isVisible,
|
||||||
private \DateTimeImmutable $createdAt
|
private bool $isAvailable = false,
|
||||||
|
private \DateTimeImmutable $createdAt = new \DateTimeImmutable()
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function getId(): string
|
public function getId(): string
|
||||||
@@ -46,6 +47,11 @@ readonly class Chapter
|
|||||||
return $this->isVisible;
|
return $this->isVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable(): bool
|
||||||
|
{
|
||||||
|
return $this->isAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCreatedAt(): \DateTimeImmutable
|
public function getCreatedAt(): \DateTimeImmutable
|
||||||
{
|
{
|
||||||
return $this->createdAt;
|
return $this->createdAt;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ readonly class ChapterListItem
|
|||||||
public ?string $title,
|
public ?string $title,
|
||||||
public ?int $volume,
|
public ?int $volume,
|
||||||
public bool $isVisible,
|
public bool $isVisible,
|
||||||
|
public bool $isAvailable,
|
||||||
public string $createdAt
|
public string $createdAt
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
@@ -52,6 +52,7 @@ readonly class GetMangaChaptersStateProvider implements ProviderInterface
|
|||||||
title: $chapter->title,
|
title: $chapter->title,
|
||||||
volume: $chapter->volume,
|
volume: $chapter->volume,
|
||||||
isVisible: $chapter->isVisible,
|
isVisible: $chapter->isVisible,
|
||||||
|
isAvailable: $chapter->isAvailable,
|
||||||
createdAt: $chapter->createdAt->format(\DateTimeInterface::RFC3339)
|
createdAt: $chapter->createdAt->format(\DateTimeInterface::RFC3339)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -222,13 +222,13 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
|
|||||||
private function toChapterDomain(EntityChapter $entity): Chapter
|
private function toChapterDomain(EntityChapter $entity): Chapter
|
||||||
{
|
{
|
||||||
return new Chapter(
|
return new Chapter(
|
||||||
new ChapterId((string) $entity->getId()),
|
id: new ChapterId((string) $entity->getId()),
|
||||||
$entity->getManga()->getId(),
|
mangaId: $entity->getManga()->getId(),
|
||||||
$entity->getNumber(),
|
number: $entity->getNumber(),
|
||||||
$entity->getTitle(),
|
title: $entity->getTitle(),
|
||||||
$entity->getVolume(),
|
volume: $entity->getVolume(),
|
||||||
$entity->isVisible(),
|
isVisible: $entity->isVisible(),
|
||||||
new \DateTimeImmutable()
|
isAvailable: $entity->getCbzPath() !== null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user