feat: user can enable/disable a watchlist

This commit is contained in:
Maël Gangloff
2025-10-25 19:23:15 +02:00
parent 5243b3c2dd
commit 24e3bc19ff
13 changed files with 212 additions and 37 deletions

View File

@@ -6,6 +6,7 @@ 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 ApiPlatform\Metadata\Put;
use App\Repository\WatchlistRepository;
@@ -95,6 +96,12 @@ use Symfony\Component\Validator\Constraints as Assert;
security: 'object.getUser() == user',
processor: WatchlistUpdateProcessor::class,
),
new Patch(
normalizationContext: ['groups' => 'watchlist:list'],
denormalizationContext: ['groups' => ['watchlist:update']],
security: 'object.getUser() == user',
processor: WatchlistUpdateProcessor::class,
),
new Delete(
security: 'object.getUser() == user'
),
@@ -208,6 +215,10 @@ class Watchlist
])]
private array $trackedEppStatus = [];
#[ORM\Column(type: Types::BOOLEAN)]
#[Groups(['watchlist:list', 'watchlist:item', 'watchlist:create', 'watchlist:update'])]
private ?bool $enabled = null;
public function __construct()
{
$this->token = Uuid::v4();
@@ -332,4 +343,16 @@ class Watchlist
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): static
{
$this->enabled = $enabled;
return $this;
}
}