throw DocumentException::
documentNotFound($documentId);
} if ($document->
getDocumentMediaFileId() !== null
) { throw new DocumentGenerationException('Document already exists'
);
} if ($document->
isStatic() === false
) { throw new DocumentGenerationException('This document is dynamically generated and cannot be overwritten'
);
} $mediaFile =
$this->mediaService->
fetchFile($uploadedFileRequest);
$fileName =
(string) $uploadedFileRequest->query->
get('fileName'
);
if ($fileName === ''
) { throw new DocumentGenerationException('Parameter "fileName" is missing'
);
} $mediaId =
$context->
scope(Context::SYSTEM_SCOPE,
fn (Context
$context): string =>
$this->mediaService->
saveMediaFile($mediaFile,
$fileName,
$context, 'document'
));
$this->connection->
executeStatement( 'UPDATE `document` SET `updated_at` = :now, `document_media_file_id` = :mediaId WHERE `id` = :id',
[