Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getReferenceId example
return
$renderedDocument
;
}
public
function
preview
(
string
$documentType
, DocumentGenerateOperation
$operation
, string
$deepLinkCode
, Context
$context
)
: RenderedDocument
{
$config
=
new
DocumentRendererConfig
(
)
;
$config
->deepLinkCode =
$deepLinkCode
;
if
(
!
empty
(
$operation
->
getConfig
(
)
[
'custom'
]
[
'invoiceNumber'
]
)
)
{
$invoiceNumber
=
(string)
$operation
->
getConfig
(
)
[
'custom'
]
[
'invoiceNumber'
]
;
$operation
->
setReferencedDocumentId
(
$this
->
getReferenceId
(
$operation
->
getOrderId
(
)
,
$invoiceNumber
)
)
;
}
$rendered
=
$this
->rendererRegistry->
render
(
$documentType
,
[
$operation
->
getOrderId
(
)
=>
$operation
]
,
$context
,
$config
)
;
if
(
!\
array_key_exists
(
$operation
->
getOrderId
(
)
,
$rendered
->
getSuccess
(
)
)
)
{
if
(
Feature::
isActive
(
'v6.6.0.0'
)
)
{
throw
DocumentException::
generationError
(
)
;
}
throw
new
InvalidOrderException
(
$operation
->
getOrderId
(
)
)
;
}