diff --git a/src/Domain/Manga/Infrastructure/ApiPlatform/Resource/DeleteMangaResource.php b/src/Domain/Manga/Infrastructure/ApiPlatform/Resource/DeleteMangaResource.php index b9bd278..9d2f2f6 100644 --- a/src/Domain/Manga/Infrastructure/ApiPlatform/Resource/DeleteMangaResource.php +++ b/src/Domain/Manga/Infrastructure/ApiPlatform/Resource/DeleteMangaResource.php @@ -5,15 +5,16 @@ namespace App\Domain\Manga\Infrastructure\ApiPlatform\Resource; use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\Delete; use App\Domain\Manga\Infrastructure\ApiPlatform\State\Processor\DeleteMangaProcessor; +use App\Domain\Manga\Infrastructure\ApiPlatform\State\Provider\DeleteMangaProvider; #[ApiResource( shortName: 'Manga', operations: [ new Delete( uriTemplate: '/mangas/{id}', + provider: DeleteMangaProvider::class, processor: DeleteMangaProcessor::class, name: 'delete_manga', - read: false, openapiContext: [ 'summary' => 'Delete a manga', 'description' => 'Permanently deletes a manga and all its associated chapters', diff --git a/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteMangaProvider.php b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteMangaProvider.php new file mode 100644 index 0000000..f440512 --- /dev/null +++ b/src/Domain/Manga/Infrastructure/ApiPlatform/State/Provider/DeleteMangaProvider.php @@ -0,0 +1,39 @@ +mangaRepository->findById($mangaId); + + if (!$manga) { + throw new MangaNotFoundException(sprintf('Manga with id %s not found', $mangaId)); + } + + return new DeleteMangaResource($mangaId); + + } catch (MangaNotFoundException $e) { + throw new NotFoundHttpException('Manga not found'); + } + } +}