feat: ajout d'une modale de gestion des chapitres, permettant la création, l'édition et le déplacement de chapitres. Mise à jour de l'API pour gérer les modifications en lot des chapitres, ainsi que l'intégration de tests pour valider cette nouvelle fonctionnalité. Amélioration de l'interface utilisateur pour une gestion plus fluide des chapitres.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-07-23 14:25:17 +02:00
parent 00d63dffeb
commit 551db0bf77
19 changed files with 2566 additions and 3 deletions

View File

@@ -0,0 +1,12 @@
<?php
namespace App\Domain\Manga\Application\Command;
readonly class ChapterEditData
{
public function __construct(
public string $id,
public ?string $title = null,
public ?int $volume = null
) {}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace App\Domain\Manga\Application\Command;
readonly class EditMultipleChapters
{
/**
* @param array<ChapterEditData> $chapters
*/
public function __construct(
public array $chapters
) {}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Domain\Manga\Application\CommandHandler;
use App\Domain\Manga\Application\Command\EditMultipleChapters;
use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
readonly class EditMultipleChaptersHandler
{
public function __construct(
private ChapterRepositoryInterface $chapterRepository
) {}
public function handle(EditMultipleChapters $command): void
{
foreach ($command->chapters as $chapterData) {
$chapter = $this->chapterRepository->findById($chapterData->id);
if (!$chapter) {
throw new ChapterNotFoundException($chapterData->id);
}
$updatedChapter = $chapter;
if ($chapterData->title !== null) {
$updatedChapter = $updatedChapter->updateTitle($chapterData->title);
}
if ($chapterData->volume !== null) {
$updatedChapter = $updatedChapter->updateVolume($chapterData->volume);
}
$this->chapterRepository->save($updatedChapter);
}
}
}