feat : bovine.reception FK + delete op + sécurités abaissées

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) <noreply@anthropic.com>
This commit is contained in:
2026-04-29 09:43:44 +02:00
parent 43d7a2514b
commit 486247bf86

View File

@@ -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;