/** @var DocumentEntity|null $document */
$document =
$this->documentRepository->
search($criteria,
$context)->
get($documentId);
if (!
$document instanceof DocumentEntity
) { if (Feature::
isActive('v6.6.0.0'
)) { throw DocumentException::
documentNotFound($documentId);
} throw new InvalidDocumentException($documentId);
} $document =
$this->
ensureDocumentMediaFileGenerated($document,
$context);
$documentMediaId =
$document->
getDocumentMediaFileId();
if ($documentMediaId === null
) { return null;
} /** @var MediaEntity $documentMedia */
$documentMedia =
$document->
getDocumentMediaFile();
$fileBlob =
$context->
scope(Context::SYSTEM_SCOPE,
fn (Context
$context): string =>
$this->mediaService->
loadFile($documentMediaId,
$context));