feat: add PATCH watchlist endpoint

This commit is contained in:
Maël Gangloff
2024-07-18 14:01:16 +02:00
parent 1533469441
commit 765c7686ac
3 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ api_platform:
version: 1.0.0 version: 1.0.0
formats: formats:
jsonld: [ 'application/ld+json' ] jsonld: [ 'application/ld+json' ]
xml: [ 'application/xml' ]
json: [ 'application/json' ] json: [ 'application/json' ]
docs_formats: docs_formats:
jsonld: [ 'application/ld+json' ] jsonld: [ 'application/ld+json' ]

View File

@@ -53,7 +53,6 @@ class WatchListController extends AbstractController
$this->em->flush(); $this->em->flush();
return $watchList; return $watchList;
} }
} }

View File

@@ -3,8 +3,10 @@
namespace App\Entity; namespace App\Entity;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Patch;
use ApiPlatform\Metadata\Post; use ApiPlatform\Metadata\Post;
use App\Repository\WatchListRepository; use App\Repository\WatchListRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
@@ -28,7 +30,12 @@ use Symfony\Component\Uid\Uuid;
routeName: 'watchlist_create', normalizationContext: ['groups' => 'watchlist:list'], routeName: 'watchlist_create', normalizationContext: ['groups' => 'watchlist:list'],
denormalizationContext: ['groups' => 'watchlist:create'], denormalizationContext: ['groups' => 'watchlist:create'],
name: 'create' name: 'create'
) ),
new Patch(
normalizationContext: ['groups' => 'watchlist:item'],
denormalizationContext: ['groups' => 'watchlist:update']
),
new Delete()
], ],
)] )]
class WatchList class WatchList
@@ -49,7 +56,7 @@ class WatchList
#[ORM\JoinTable(name: 'watch_lists_domains', #[ORM\JoinTable(name: 'watch_lists_domains',
joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')], joinColumns: [new ORM\JoinColumn(name: 'watch_list_token', referencedColumnName: 'token')],
inverseJoinColumns: [new ORM\JoinColumn(name: 'domain_ldh_name', referencedColumnName: 'ldh_name')])] 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; private Collection $domains;
public function __construct() public function __construct()