$elementId, 'type' => $type, 'signRequestId' => $signRequestId, 'coordinates' => $coordinates, 'metadata' => $metadata, 'fileUuid' => $uuid, ]; try { $this->validateHelper->validateVisibleElement($visibleElement, ValidateHelper::TYPE_VISIBLE_ELEMENT_PDF); $this->validateHelper->validateExistingFile([ 'uuid' => $uuid, 'userManager' => $this->userSession->getUser() ]); $this->validateHelper->signerCanHaveVisibleElement($signRequestId); $fileElement = $this->fileElementService->saveVisibleElement($visibleElement, $uuid); $return = [ 'fileElementId' => $fileElement->getId(), ]; $statusCode = Http::STATUS_OK; } catch (\Throwable $th) { $this->logger->error($th->getMessage()); $return = [ 'errors' => [$th->getMessage()] ]; $statusCode = $th->getCode() > 0 ? $th->getCode() : Http::STATUS_NOT_FOUND; } return new JSONResponse($return, $statusCode); } #[NoAdminRequired] #[NoCSRFRequired] public function patch(string $uuid, int $signRequestId, int $elementId = null, string $type = '', array $metadata = [], array $coordinates = []): JSONResponse { return $this->post($uuid, $signRequestId, $elementId, $type, $metadata, $coordinates); } #[NoAdminRequired] #[NoCSRFRequired] public function delete(string $uuid, int $elementId): JSONResponse { try { $this->validateHelper->validateExistingFile([ 'uuid' => $uuid, 'userManager' => $this->userSession->getUser() ]); $this->validateHelper->validateAuthenticatedUserIsOwnerOfPdfVisibleElement($elementId, $this->userSession->getUser()->getUID()); $this->fileElementService->deleteVisibleElement($elementId); $return = []; $statusCode = Http::STATUS_OK; } catch (\Throwable $th) { $this->logger->error($th->getMessage()); $return = [ 'errors' => [$th->getMessage()] ]; $statusCode = $th->getCode() > 0 ? $th->getCode() : Http::STATUS_NOT_FOUND; } return new JSONResponse($return, $statusCode); } }