From 667e144681c3cc5430a94295d01b02ca459b6c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 4 Sep 2024 14:09:53 +0200 Subject: [PATCH] Add PDF signature zone availability checks Introduce `PDFSignatureZoneAvailable` service to check available PDF signature zones. Updated `WorkflowAddSignatureController` to use the new service. Added unit tests to verify the correctness of the functionality. --- .../Service/Signature/PDFSignatureZoneAvailable.php | 2 +- .../Controller/WorkflowAddSignatureController.php | 2 +- src/Bundle/ChillMainBundle/Controller/WorkflowController.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneAvailable.php b/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneAvailable.php index 9a7fe8437..d4109632a 100644 --- a/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneAvailable.php +++ b/src/Bundle/ChillDocStoreBundle/Service/Signature/PDFSignatureZoneAvailable.php @@ -47,7 +47,7 @@ class PDFSignatureZoneAvailable $this->collectSignaturesInUse($entityWorkflow) ); - return array_filter($zones, fn (PDFSignatureZone $zone) => !in_array($zone->index, $signatureZonesIndexes, true)); + return array_values(array_filter($zones, fn (PDFSignatureZone $zone) => !in_array($zone->index, $signatureZonesIndexes, true))); } /** diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php index 5024f6684..353976402 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowAddSignatureController.php @@ -30,7 +30,7 @@ final readonly class WorkflowAddSignatureController private Environment $twig ) {} - #[Route(path: '/{_locale}/main/workflow/signature/{id}/sign', name: 'chill_main_workflow_signature', methods: 'GET')] + #[Route(path: '/{_locale}/main/workflow/signature/{id}/sign', name: 'chill_main_workflow_signature_add', methods: 'GET')] public function __invoke(EntityWorkflowStepSignature $signature, Request $request): Response { $entityWorkflow = $signature->getStep()->getEntityWorkflow(); diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 8b6944a2c..277a18142 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -377,7 +377,7 @@ class WorkflowController extends AbstractController $signature = $this->entityManager->getRepository(EntityWorkflowStepSignature::class)->find($signature_id); if ($signature->getSigner() instanceof User) { - return $this->redirectToRoute('chill_main_workflow_signature', ['signature_id' => $signature_id]); + return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]); } $metadataForm = $this->createForm(WorkflowSignatureMetadataType::class); @@ -401,7 +401,7 @@ class WorkflowController extends AbstractController $this->entityManager->persist($signature); $this->entityManager->flush(); - return $this->redirectToRoute('chill_main_workflow_signature', ['signature_id' => $signature_id]); + return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]); } return $this->render(