mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
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.
This commit is contained in:
@@ -11,11 +11,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Controller;
|
||||
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZoneParser;
|
||||
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
|
||||
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZoneAvailable;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
|
||||
use Chill\MainBundle\Workflow\EntityWorkflowManager;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -23,21 +21,18 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
final class WorkflowAddSignatureController
|
||||
final readonly class WorkflowAddSignatureController
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly EntityWorkflowManager $entityWorkflowManager,
|
||||
private readonly StoredObjectManagerInterface $storedObjectManager,
|
||||
private readonly PDFSignatureZoneParser $PDFSignatureZoneParser,
|
||||
private readonly NormalizerInterface $normalizer,
|
||||
private readonly Environment $twig
|
||||
private EntityWorkflowManager $entityWorkflowManager,
|
||||
private PDFSignatureZoneAvailable $PDFSignatureZoneAvailable,
|
||||
private NormalizerInterface $normalizer,
|
||||
private Environment $twig
|
||||
) {}
|
||||
|
||||
#[Route(path: '/{_locale}/main/workflow/signature/{signature_id}/sign', name: 'chill_main_workflow_signature', methods: 'GET')]
|
||||
public function __invoke(int $signature_id, Request $request, WorkflowController $workflowController): Response
|
||||
#[Route(path: '/{_locale}/main/workflow/signature/{id}/sign', name: 'chill_main_workflow_signature', methods: 'GET')]
|
||||
public function __invoke(EntityWorkflowStepSignature $signature, Request $request): Response
|
||||
{
|
||||
$signature = $this->entityManager->getRepository(EntityWorkflowStepSignature::class)->find($signature_id);
|
||||
$entityWorkflow = $signature->getStep()->getEntityWorkflow();
|
||||
|
||||
$storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow);
|
||||
@@ -45,20 +40,18 @@ final class WorkflowAddSignatureController
|
||||
throw new NotFoundHttpException('No stored object found');
|
||||
}
|
||||
|
||||
$zones = [];
|
||||
$content = $this->storedObjectManager->read($storedObject);
|
||||
if (null != $content) {
|
||||
$zones = $this->PDFSignatureZoneParser->findSignatureZones($content);
|
||||
}
|
||||
$zones = $this->PDFSignatureZoneAvailable->getAvailableSignatureZones($entityWorkflow);
|
||||
|
||||
$signatureClient = [];
|
||||
$signatureClient['id'] = $signature->getId();
|
||||
$signatureClient['storedObject'] = $this->normalizer->normalize($storedObject, 'json');
|
||||
$signatureClient['zones'] = $zones;
|
||||
|
||||
return new Response($this->twig->render(
|
||||
'@ChillMain/Workflow/_signature_sign.html.twig',
|
||||
['signature' => $signatureClient]
|
||||
));
|
||||
return new Response(
|
||||
$this->twig->render(
|
||||
'@ChillMain/Workflow/_signature_sign.html.twig',
|
||||
['signature' => $signatureClient]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user