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:
@@ -10,6 +10,7 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
|||||||
use ApiPlatform\Metadata\ApiFilter;
|
use ApiPlatform\Metadata\ApiFilter;
|
||||||
use ApiPlatform\Metadata\ApiProperty;
|
use ApiPlatform\Metadata\ApiProperty;
|
||||||
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\Patch;
|
||||||
@@ -34,6 +35,7 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|||||||
'sex' => 'exact',
|
'sex' => 'exact',
|
||||||
'buildingCase' => 'exact',
|
'buildingCase' => 'exact',
|
||||||
'receivedWeight' => 'exact',
|
'receivedWeight' => 'exact',
|
||||||
|
'reception' => 'exact',
|
||||||
])]
|
])]
|
||||||
#[ApiFilter(DateFilter::class, properties: ['arrivalDate', 'birthDate', 'exitDate'])]
|
#[ApiFilter(DateFilter::class, properties: ['arrivalDate', 'birthDate', 'exitDate'])]
|
||||||
#[ApiFilter(ExistsFilter::class, properties: ['exitedAt'])]
|
#[ApiFilter(ExistsFilter::class, properties: ['exitedAt'])]
|
||||||
@@ -50,16 +52,20 @@ use Symfony\Component\Serializer\Normalizer\DateTimeNormalizer;
|
|||||||
new Post(
|
new Post(
|
||||||
normalizationContext: ['groups' => ['bovine:read']],
|
normalizationContext: ['groups' => ['bovine:read']],
|
||||||
denormalizationContext: ['groups' => ['bovine:write']],
|
denormalizationContext: ['groups' => ['bovine:write']],
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
security: "is_granted('ROLE_USER')",
|
||||||
processor: BovineProcessor::class,
|
processor: BovineProcessor::class,
|
||||||
),
|
),
|
||||||
new Patch(
|
new Patch(
|
||||||
requirements: ['id' => '\d+'],
|
requirements: ['id' => '\d+'],
|
||||||
normalizationContext: ['groups' => ['bovine:read']],
|
normalizationContext: ['groups' => ['bovine:read']],
|
||||||
denormalizationContext: ['groups' => ['bovine:write']],
|
denormalizationContext: ['groups' => ['bovine:write']],
|
||||||
security: "is_granted('ROLE_ADMIN')",
|
security: "is_granted('ROLE_USER')",
|
||||||
processor: BovineProcessor::class,
|
processor: BovineProcessor::class,
|
||||||
),
|
),
|
||||||
|
new Delete(
|
||||||
|
requirements: ['id' => '\d+'],
|
||||||
|
security: "is_granted('ROLE_USER')",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
security: "is_granted('ROLE_USER')",
|
security: "is_granted('ROLE_USER')",
|
||||||
)]
|
)]
|
||||||
@@ -94,6 +100,12 @@ class Bovine
|
|||||||
#[ApiProperty(readableLink: true)]
|
#[ApiProperty(readableLink: true)]
|
||||||
private ?BuildingCase $buildingCase = null;
|
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]
|
#[ORM\ManyToOne]
|
||||||
#[Groups(['bovine:read'])]
|
#[Groups(['bovine:read'])]
|
||||||
#[ApiProperty(readableLink: true)]
|
#[ApiProperty(readableLink: true)]
|
||||||
@@ -211,6 +223,18 @@ class Bovine
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getReception(): ?Reception
|
||||||
|
{
|
||||||
|
return $this->reception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setReception(?Reception $reception): static
|
||||||
|
{
|
||||||
|
$this->reception = $reception;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function getBuilding(): ?Building
|
public function getBuilding(): ?Building
|
||||||
{
|
{
|
||||||
return $this->building;
|
return $this->building;
|
||||||
|
|||||||
Reference in New Issue
Block a user