Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getDocumentType example
$operation
=
new
DocumentGenerateOperation
(
$document
->
getOrderId
(
)
,
FileTypes::PDF,
$document
->
getConfig
(
)
,
$document
->
getReferencedDocumentId
(
)
)
;
$operation
->
setDocumentId
(
$document
->
getId
(
)
)
;
/** @var DocumentTypeEntity $documentType */
$documentType
=
$document
->
getDocumentType
(
)
;
$documentStruct
=
$this
->documentGenerator->
generate
(
$documentType
->
getTechnicalName
(
)
,
[
$document
->
getOrderId
(
)
=>
$operation
]
,
$context
)
->
getSuccess
(
)
->
first
(
)
;
if
(
$documentStruct
=== null
)
{
return
null;
}
$operation
=
new
DocumentGenerateOperation
(
$document
->
getOrderId
(
)
,
FileTypes::PDF,
$document
->
getConfig
(
)
,
$document
->
getReferencedDocumentId
(
)
)
;
$operation
->
setDocumentId
(
$documentId
)
;
/** @var DocumentTypeEntity $documentType */
$documentType
=
$document
->
getDocumentType
(
)
;
$documentStruct
=
$this
->
generate
(
$documentType
->
getTechnicalName
(
)
,
[
$document
->
getOrderId
(
)
=>
$operation
]
,
$context
)
->
getSuccess
(
)
->
first
(
)
;
if
(
$documentStruct
=== null
)
{
return
$document
;
}
$criteria
=
new
Criteria
(
[
$documentStruct
->
getId
(
)
]
)
;
$criteria
->
addAssociation
(
'documentType'
)
;
/** @var DocumentEntity $document */
$document
=
$this
->documentRepository
->
search
(
$criteria
,
$this
->context
)
->
get
(
$documentStruct
->
getId
(
)
)
;
static
::
assertNotNull
(
$document
)
;
static
::
assertSame
(
$this
->orderId,
$document
->
getOrderId
(
)
)
;
static
::
assertNotNull
(
$document
->
getDocumentType
(
)
)
;
static
::
assertSame
(
Defaults::LIVE_VERSION,
$document
->
getOrderVersionId
(
)
)
;
static
::
assertSame
(
DeliveryNoteRenderer::TYPE,
$document
->
getDocumentType
(
)
->
getTechnicalName
(
)
)
;
static
::
assertSame
(
FileTypes::PDF,
$document
->
getFileType
(
)
)
;
}
public
function
testGenerateEmpty
(
)
: void
{
$documentStruct
=
$this
->documentGenerator->
generate
(
DeliveryNoteRenderer::TYPE,
[
]
,
$this
->context
)
->
getSuccess
(
)
;
static
::
assertCount
(
0,
$documentStruct
)
;