signature: check for signature state

This commit is contained in:
nobohan
2024-07-12 11:52:22 +02:00
parent 77da2c1ac6
commit 421226c0dc
3 changed files with 85 additions and 34 deletions

View File

@@ -17,6 +17,8 @@ use Chill\DocStoreBundle\Service\Signature\PDFPage;
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSignatureStateEnum;
use Chill\MainBundle\Workflow\EntityWorkflowManager;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Messenger\MessageBusInterface;
@@ -27,26 +29,20 @@ class SignatureRequestController
public function __construct(
private MessageBusInterface $messageBus,
private StoredObjectManagerInterface $storedObjectManager,
private EntityWorkflowManager $entityWorkflowManager,
) {}
#[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')]
//public function processSignature(EntityWorkflowStepSignature $signature): Response // using ParamConverter
public function processSignature(EntityWorkflowStepSignature $signature, Request $request): JsonResponse
{
dump($signature);
// $signature = $this->signatureRepository($signature); //not useful?
// $entityWorkflow = $signature->getStep()->getEntityWorkflow();
// $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow);
$content = 'blop';// $this->storedObjectManager->read($storedObject);
dump($request);
// TODO parse payload: json_decode ou, mieux, dataTransfertObject
// dump($request);
$data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR);
$data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); // TODO parse payload: json_decode ou, mieux, dataTransfertObject
dump($data);
$signatureId = 1;
$storedObjectId = 9; //$data['storedObject']['id'];
$content = 'blop';// $this->storedObjectManager->read($storedObjectId);
$zone = new PDFSignatureZone(
$data['zone']['index'],
$data['zone']['x'],
@@ -57,7 +53,7 @@ class SignatureRequestController
);
$this->messageBus->dispatch(new RequestPdfSignMessage(
$signatureId,
$signature->getId(),
$zone,
$data['zone']['index'],
'test signature', //reason (string)
@@ -67,4 +63,10 @@ class SignatureRequestController
return new JsonResponse(null, JsonResponse::HTTP_OK, []);
}
#[Route('/api/1.0/document/workflow/{id}/check-signature', name: 'chill_docstore_check_signature')]
public function checkSignature(EntityWorkflowStepSignature $signature): JsonResponse
{
return new JsonResponse($signature->getState(), JsonResponse::HTTP_OK, []);
}
}