signature: add index on PDFSignatureZone + init POST signature

This commit is contained in:
nobohan
2024-07-11 08:06:18 +02:00
parent 39d3ba2f40
commit 77da2c1ac6
7 changed files with 66 additions and 20 deletions

View File

@@ -16,7 +16,9 @@ use Chill\DocStoreBundle\Service\Signature\Driver\BaseSigner\RequestPdfSignMessa
use Chill\DocStoreBundle\Service\Signature\PDFPage;
use Chill\DocStoreBundle\Service\Signature\PDFSignatureZone;
use Chill\DocStoreBundle\Service\StoredObjectManagerInterface;
use Symfony\Component\HttpFoundation\Response;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Annotation\Route;
@@ -28,19 +30,41 @@ class SignatureRequestController
) {}
#[Route('/api/1.0/document/workflow/{id}/signature-request', name: 'chill_docstore_signature_request')]
public function processSignature(StoredObject $storedObject): Response
//public function processSignature(EntityWorkflowStepSignature $signature): Response // using ParamConverter
public function processSignature(EntityWorkflowStepSignature $signature, Request $request): JsonResponse
{
$content = $this->storedObjectManager->read($storedObject);
dump($signature);
// $signature = $this->signatureRepository($signature); //not useful?
// $entityWorkflow = $signature->getStep()->getEntityWorkflow();
// $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow);
dump($request);
// TODO parse payload: json_decode ou, mieux, dataTransfertObject
// dump($request);
$data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR);
dump($data);
$signatureId = 1;
$storedObjectId = 9; //$data['storedObject']['id'];
$content = 'blop';// $this->storedObjectManager->read($storedObjectId);
$zone = new PDFSignatureZone(
$data['zone']['index'],
$data['zone']['x'],
$data['zone']['y'],
$data['zone']['height'],
$data['zone']['width'],
$page = new PDFPage($data['zone']['PDFPage']['index'], $data['zone']['PDFPage']['width'], $data['zone']['PDFPage']['height'])
);
$this->messageBus->dispatch(new RequestPdfSignMessage(
0,
new PDFSignatureZone(10.0, 10.0, 180.0, 180.0, new PDFPage(0, 500.0, 800.0)),
0,
'test signature',
'Mme Caroline Diallo',
$signatureId,
$zone,
$data['zone']['index'],
'test signature', //reason (string)
'Mme Caroline Diallo', //signerText (string)
$content
));
return new Response('<html><head><title>test</title></head><body><p>ok</p></body></html>');
return new JsonResponse(null, JsonResponse::HTTP_OK, []);
}
}