feat(documents) : accept type on upload + expose in query controller + PATCH tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Matthieu
2026-03-23 15:20:39 +01:00
parent 8d920d5f65
commit 5ec6e49af2
3 changed files with 58 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ namespace App\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Entity\Document;
use App\Enum\DocumentType;
use App\Service\DocumentStorageService;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
@@ -76,6 +77,10 @@ final class DocumentUploadProcessor implements ProcessorInterface
$document->setMimeType($mimeType);
$document->setSize((int) $size);
$typeValue = $request->request->get('type', 'documentation');
$docType = DocumentType::tryFrom($typeValue) ?? DocumentType::DOCUMENTATION;
$document->setType($docType);
// Handle entity relations from form fields
$this->setRelationsFromRequest($document, $request);