Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
documentNotFound example
$criteria
->
addAssociations
(
[
'documentMediaFile',
'documentType',
]
)
;
/** @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;
}