feat: ajout de la fonctionnalité d'édition des mangas, incluant la création d'un modal d'édition, la mise à jour de l'API pour gérer les modifications, et l'intégration de la logique de gestion des erreurs. Tests ajoutés pour valider le bon fonctionnement de l'édition.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-30 20:00:09 +02:00
parent 896c57ac34
commit 9255509042
20 changed files with 1185 additions and 11 deletions

View File

@@ -63,9 +63,17 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
return $entity ? $this->toDomain($entity) : null;
}
public function save(DomainManga $manga): void
public function save(DomainManga $manga): void
{
$entity = new EntityManga();
// Check if this is an update (manga has a numeric ID) or a new creation
$entity = null;
if ($manga->getId() && $manga->getId()->getValue() && is_numeric($manga->getId()->getValue())) {
$entity = $this->entityManager->find(EntityManga::class, (int) $manga->getId()->getValue());
}
if (!$entity) {
$entity = new EntityManga();
}
$imageUrls = $manga->getImageUrls();
$fullImageUrl = $imageUrls?->getFull();
@@ -78,10 +86,19 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
->setPublicationYear($manga->getPublicationYear())
->setGenres($manga->getGenres())
->setStatus($manga->getStatus())
->setExternalId($manga->getExternalId()->getValue())
->setImageUrl($fullImageUrl ?? null)
->setThumbnailUrl($thumbnailUrl ?? null)
->setMonitored(false);
->setAlternativeSlugs($manga->getAlternativeSlugs());
// Only set externalId if it exists (to avoid setting null on update)
if ($manga->getExternalId()) {
$entity->setExternalId($manga->getExternalId()->getValue());
}
// Only set monitored for new entities
if (!$entity->getId()) {
$entity->setMonitored(false);
}
if ($manga->getRating() !== null) {
$entity->setRating($manga->getRating());
@@ -239,6 +256,7 @@ readonly class LegacyMangaRepository implements MangaRepositoryInterface
imageUrl: $entity->getImageUrl(),
rating: $entity->getRating(),
imageUrls: $entity->getImageUrl() ? new ImageUrls($entity->getImageUrl() ?? '', $entity->getThumbnailUrl() ?? '') : null,
alternativeSlugs: $entity->getAlternativeSlugs() ?? [],
createdAt: $entity->getCreatedAt(),
);
}