feat(documents) : add DocumentType enum and type column on entity
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,11 @@ use ApiPlatform\Metadata\ApiResource;
|
|||||||
use ApiPlatform\Metadata\Delete;
|
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\Post;
|
use ApiPlatform\Metadata\Post;
|
||||||
use ApiPlatform\Metadata\Put;
|
use ApiPlatform\Metadata\Put;
|
||||||
use App\Entity\Trait\CuidEntityTrait;
|
use App\Entity\Trait\CuidEntityTrait;
|
||||||
|
use App\Enum\DocumentType;
|
||||||
use App\Repository\DocumentRepository;
|
use App\Repository\DocumentRepository;
|
||||||
use App\State\DocumentUploadProcessor;
|
use App\State\DocumentUploadProcessor;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
@@ -46,6 +48,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
|||||||
inputFormats: ['multipart' => ['multipart/form-data']],
|
inputFormats: ['multipart' => ['multipart/form-data']],
|
||||||
),
|
),
|
||||||
new Put(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
new Put(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
||||||
|
new Patch(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
||||||
new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
new Delete(security: "is_granted('ROLE_GESTIONNAIRE')"),
|
||||||
],
|
],
|
||||||
paginationClientItemsPerPage: true,
|
paginationClientItemsPerPage: true,
|
||||||
@@ -105,6 +108,10 @@ class Document
|
|||||||
#[Groups(['document:list'])]
|
#[Groups(['document:list'])]
|
||||||
private ?Site $site = null;
|
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')]
|
#[ORM\Column(type: Types::DATETIME_IMMUTABLE, name: 'createdAt')]
|
||||||
#[Groups(['document:list'])]
|
#[Groups(['document:list'])]
|
||||||
private DateTimeImmutable $createdAt;
|
private DateTimeImmutable $createdAt;
|
||||||
@@ -237,4 +244,16 @@ class Document
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getType(): DocumentType
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(DocumentType $type): static
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/Enum/DocumentType.php
Normal file
15
src/Enum/DocumentType.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace App\Enum;
|
||||||
|
|
||||||
|
enum DocumentType: string
|
||||||
|
{
|
||||||
|
case DOCUMENTATION = 'documentation';
|
||||||
|
case DEVIS = 'devis';
|
||||||
|
case FACTURE = 'facture';
|
||||||
|
case PLAN = 'plan';
|
||||||
|
case PHOTO = 'photo';
|
||||||
|
case AUTRE = 'autre';
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user