Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
EntityBusinessEvent example
public
static
function
getEventsWithPermissions
(
)
: array
{
$tax
=
new
TaxEntity
(
)
;
$tax
->
setId
(
'tax-id'
)
;
$tax
->
setName
(
'test'
)
;
$tax
->
setTaxRate
(
19
)
;
$tax
->
setPosition
(
1
)
;
return
[
[
new
EntityBusinessEvent
(
$tax
)
]
,
[
new
CollectionBusinessEvent
(
new
TaxCollection
(
[
$tax
]
)
)
]
,
[
new
ArrayBusinessEvent
(
new
TaxCollection
(
[
$tax
]
)
)
]
,
[
new
NestedEntityBusinessEvent
(
$tax
)
]
,
]
;
}
}
return
'test';
}
public
function
getContext
(
)
: Context
{
return
Context::
createDefaultContext
(
)
;
}
public
function
getObject
(
)
: EntityBusinessEvent
{
return
new
EntityBusinessEvent
(
$this
->tax
)
;
}
}
$tax
=
new
TaxEntity
(
)
;
$tax
->
setId
(
'tax-id'
)
;
$tax
->
setName
(
'test'
)
;
$tax
->
setTaxRate
(
19
)
;
$tax
->
setPosition
(
1
)
;
yield
'ScalarBusinessEvent' =>
[
new
ScalarBusinessEvent
(
)
]
;
yield
'StructuredObjectBusinessEvent' =>
[
new
StructuredObjectBusinessEvent
(
)
]
;
yield
'StructuredArrayObjectBusinessEvent' =>
[
new
StructuredArrayObjectBusinessEvent
(
)
]
;
yield
'UnstructuredObjectBusinessEvent' =>
[
new
UnstructuredObjectBusinessEvent
(
)
]
;
yield
'EntityBusinessEvent' =>
[
new
EntityBusinessEvent
(
$tax
)
]
;
yield
'CollectionBusinessEvent' =>
[
new
CollectionBusinessEvent
(
new
TaxCollection
(
[
$tax
]
)
)
]
;
yield
'ArrayBusinessEvent' =>
[
new
ArrayBusinessEvent
(
new
TaxCollection
(
[
$tax
]
)
)
]
;
yield
'NestedEntityBusinessEvent' =>
[
new
NestedEntityBusinessEvent
(
$tax
)
]
;
}
public
function
testInvalidType
(
)
: void
{
static
::
expectException
(
\RuntimeException::
class
)
;
$this
->businessEventEncoder->
encode
(
new
InvalidTypeBusinessEvent
(
)
)
;
}