Merge branch 'main' of ssh://git.homelab.nestor-server.fr:2222/colgora/Mangarr
All checks were successful
Build and Deploy / deploy (push) Successful in 1m46s

# Conflicts:
#	src/Domain/Manga/Application/CommandHandler/DeleteChapterHandler.php
#	src/Domain/Manga/Application/CommandHandler/EditMultipleChaptersHandler.php
#	src/Domain/Manga/Application/EventListener/ChapterImportedEventListener.php
#	src/Domain/Manga/Application/EventListener/VolumeImportedEventListener.php
#	src/Domain/Manga/Application/Response/ChapterResponse.php
#	src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteCbzProvider.php
#	src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteChapterProvider.php
#	src/Domain/Manga/Infrastructure/Persistence/Repository/LegacyChapterRepository.php
This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2026-03-09 20:47:43 +01:00
33 changed files with 549 additions and 550 deletions

View File

@@ -3,36 +3,36 @@
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\Contract\Repository\MangaRepositoryInterface;
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
readonly class EditMultipleChaptersHandler
{
public function __construct(
private ChapterRepositoryInterface $chapterRepository
private MangaRepositoryInterface $mangaRepository
) {
}
public function handle(EditMultipleChapters $command): void
{
foreach ($command->chapters as $chapterData) {
$chapter = $this->chapterRepository->findById($chapterData->id);
$chapter = $this->mangaRepository->findChapterById($chapterData->id);
if (!$chapter) {
throw new ChapterNotFoundException($chapterData->id);
}
$updatedChapter = $chapter;
$manga = $this->mangaRepository->findById($chapter->getMangaId()->getValue());
if ($chapterData->title !== null) {
$updatedChapter = $updatedChapter->updateTitle($chapterData->title);
$manga->updateChapterTitle($chapter, $chapterData->title);
}
if ($chapterData->volume !== null) {
$updatedChapter = $updatedChapter->updateVolume($chapterData->volume);
$manga->updateChapterVolume($chapter, $chapterData->volume);
}
$this->chapterRepository->save($updatedChapter);
$this->mangaRepository->save($manga);
}
}
}