From 342b0afdbb3de1c9f315e1ea4810fce8def344b3 Mon Sep 17 00:00:00 2001 From: Matthieu Date: Mon, 23 Mar 2026 15:09:49 +0100 Subject: [PATCH] feat(documents) : add DocumentType enum and type column on entity Co-Authored-By: Claude Opus 4.6 (1M context) --- src/Entity/Document.php | 19 +++++++++++++++++++ src/Enum/DocumentType.php | 15 +++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/Enum/DocumentType.php diff --git a/src/Entity/Document.php b/src/Entity/Document.php index 867ae15..b8b9fc7 100644 --- a/src/Entity/Document.php +++ b/src/Entity/Document.php @@ -12,9 +12,11 @@ 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\Entity\Trait\CuidEntityTrait; +use App\Enum\DocumentType; use App\Repository\DocumentRepository; use App\State\DocumentUploadProcessor; use DateTimeImmutable; @@ -46,6 +48,7 @@ use Symfony\Component\Serializer\Attribute\Groups; inputFormats: ['multipart' => ['multipart/form-data']], ), new Put(security: "is_granted('ROLE_GESTIONNAIRE')"), + new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"), new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"), ], paginationClientItemsPerPage: true, @@ -105,6 +108,10 @@ class Document #[Groups(['document:list'])] private ?Site $site = null; + #[ORM\Column(type: Types::STRING, length: 20, enumType: DocumentType::class)] + #[Groups(['document:list', 'document:read', 'composant:read', 'piece:read', 'product:read'])] + private DocumentType $type = DocumentType::DOCUMENTATION; + #[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')] #[Groups(['document:list'])] private DateTimeImmutable $createdAt; @@ -237,4 +244,16 @@ class Document return $this; } + + public function getType(): DocumentType + { + return $this->type; + } + + public function setType(DocumentType $type): static + { + $this->type = $type; + + return $this; + } } diff --git a/src/Enum/DocumentType.php b/src/Enum/DocumentType.php new file mode 100644 index 0000000..8f862b6 --- /dev/null +++ b/src/Enum/DocumentType.php @@ -0,0 +1,15 @@ +