From 765c7686ac0aad8deec2205fef752f856b05e256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Thu, 18 Jul 2024 14:01:16 +0200 Subject: [PATCH] feat: add PATCH watchlist endpoint --- config/packages/api_platform.yaml | 1 + src/Controller/WatchListController.php | 1 - src/Entity/WatchList.php | 11 +++++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config/packages/api_platform.yaml b/config/packages/api_platform.yaml index d7e6ac1..695bcaf 100644 --- a/config/packages/api_platform.yaml +++ b/config/packages/api_platform.yaml @@ -3,6 +3,7 @@ api_platform: version: 1.0.0 formats: jsonld: [ 'application/ld+json' ] + xml: [ 'application/xml' ] json: [ 'application/json' ] docs_formats: jsonld: [ 'application/ld+json' ] diff --git a/src/Controller/WatchListController.php b/src/Controller/WatchListController.php index 0fcb621..f7ba7e3 100644 --- a/src/Controller/WatchListController.php +++ b/src/Controller/WatchListController.php @@ -53,7 +53,6 @@ class WatchListController extends AbstractController $this->em->flush(); return $watchList; - } } \ No newline at end of file diff --git a/src/Entity/WatchList.php b/src/Entity/WatchList.php index ef18f06..4a8959f 100644 --- a/src/Entity/WatchList.php +++ b/src/Entity/WatchList.php @@ -3,8 +3,10 @@ namespace App\Entity; use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; +use ApiPlatform\Metadata\Patch; use ApiPlatform\Metadata\Post; use App\Repository\WatchListRepository; use Doctrine\Common\Collections\ArrayCollection; @@ -28,7 +30,12 @@ use Symfony\Component\Uid\Uuid; routeName: 'watchlist_create', normalizationContext: ['groups' => 'watchlist:list'], denormalizationContext: ['groups' => 'watchlist:create'], name: 'create' - ) + ), + new Patch( + normalizationContext: ['groups' => 'watchlist:item'], + denormalizationContext: ['groups' => 'watchlist:update'] + ), + new Delete() ], )] class WatchList @@ -49,7 +56,7 @@ class WatchList #[ORM\JoinTable(name: 'watch_lists_domains', joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')], inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')])] - #[Groups(['watchlist:item', 'watchlist:create'])] + #[Groups(['watchlist:item', 'watchlist:create', 'watchlist:update'])] private Collection $domains; public function __construct()