security->isGranted(EntityWorkflowStepSignatureVoter::SIGN, $signature)) { throw new AccessDeniedHttpException('not authorized to sign this step'); } $entityWorkflow = $signature->getStep()->getEntityWorkflow(); if (EntityWorkflowSignatureStateEnum::PENDING !== $signature->getState()) { return new JsonResponse([], status: Response::HTTP_CONFLICT); } $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow); if ('application/pdf' !== $storedObject->getType()) { [$storedObject, $storedObjectVersion, $content] = $this->converter->addConvertedVersion($storedObject, $request->getLocale(), includeConvertedContent: true); $this->entityManager->persist($storedObjectVersion); $this->entityManager->flush(); } else { $content = $this->storedObjectManager->read($storedObject); } $data = \json_decode((string) $request->getContent(), true, 512, JSON_THROW_ON_ERROR); $zone = new PDFSignatureZone( $data['zone']['index'], $data['zone']['x'], $data['zone']['y'], $data['zone']['height'], $data['zone']['width'], new PDFPage($data['zone']['PDFPage']['index'], $data['zone']['PDFPage']['width'], $data['zone']['PDFPage']['height']) ); $this->messageBus->dispatch(new RequestPdfSignMessage( $signature->getId(), $zone, $data['zone']['index'], 'Signed by IP: '.(string) $request->getClientIp().', authenticated user: '.$this->entityRender->renderString($this->security->getUser(), []), $this->entityRender->renderString($signature->getSigner(), [ // options for user render 'absence' => false, 'main_scope' => false, UserRender::SPLIT_LINE_BEFORE_CHARACTER => 30, // options for person render 'addAge' => false, ]), $content )); 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 { $entityWorkflow = $signature->getStep()->getEntityWorkflow(); $storedObject = $this->entityWorkflowManager->getAssociatedStoredObject($entityWorkflow); return new JsonResponse( [ 'state' => $signature->getState(), 'storedObject' => $this->normalizer->normalize($storedObject, 'json'), ], JsonResponse::HTTP_OK, [] ); } }