From 486247bf86fec77cba0ae6c06cbd79d97d13511f Mon Sep 17 00:00:00 2001 From: tristan Date: Wed, 29 Apr 2026 09:43:44 +0200 Subject: [PATCH] =?UTF-8?q?feat=20:=20bovine.reception=20FK=20+=20delete?= =?UTF-8?q?=20op=20+=20s=C3=A9curit=C3=A9s=20abaiss=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout d'une relation ManyToOne nullable vers Reception, d'un SearchFilter exact, d'une opération DELETE et abaissement de la sécurité Post/Patch/Delete de ROLE_ADMIN à ROLE_USER pour le flux métier opérationnel d'entrée/sortie. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/Entity/Bovine.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/Entity/Bovine.php b/src/Entity/Bovine.php index 656fd78..99ca8bc 100644 --- a/src/Entity/Bovine.php +++ b/src/Entity/Bovine.php @@ -10,6 +10,7 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiProperty; use ApiPlatform\Metadata\ApiResource; +use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Get; use ApiPlatform\Metadata\GetCollection; use ApiPlatform\Metadata\Patch; @@ -34,6 +35,7 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; 'sex' => 'exact', 'buildingCase' => 'exact', 'receivedWeight' => 'exact', + 'reception' => 'exact', ])] #[ApiFilter(DateFilter::class, properties: ['arrivalDate', 'birthDate', 'exitDate'])] #[ApiFilter(ExistsFilter::class, properties: ['exitedAt'])] @@ -50,16 +52,20 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer; new Post( normalizationContext: ['groups' => ['bovine:read']], denormalizationContext: ['groups' => ['bovine:write']], - security: "is_granted('ROLE_ADMIN')", + security: "is_granted('ROLE_USER')", processor: BovineProcessor::class, ), new Patch( requirements: ['id' => '\d+'], normalizationContext: ['groups' => ['bovine:read']], denormalizationContext: ['groups' => ['bovine:write']], - security: "is_granted('ROLE_ADMIN')", + security: "is_granted('ROLE_USER')", processor: BovineProcessor::class, ), + new Delete( + requirements: ['id' => '\d+'], + security: "is_granted('ROLE_USER')", + ), ], security: "is_granted('ROLE_USER')", )] @@ -94,6 +100,12 @@ class Bovine #[ApiProperty(readableLink: true)] private ?BuildingCase $buildingCase = null; + #[ORM\ManyToOne(inversedBy: 'bovines')] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] + #[Groups(['bovine:read', 'bovine:write'])] + #[ApiProperty(readableLink: false)] + private ?Reception $reception = null; + #[ORM\ManyToOne] #[Groups(['bovine:read'])] #[ApiProperty(readableLink: true)] @@ -211,6 +223,18 @@ class Bovine return $this; } + public function getReception(): ?Reception + { + return $this->reception; + } + + public function setReception(?Reception $reception): static + { + $this->reception = $reception; + + return $this; + } + public function getBuilding(): ?Building { return $this->building;