Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
filterSystemDefaults example
$ids
=
[
]
;
$writeCommands
=
$event
->
getCommands
(
)
;
foreach
(
$writeCommands
as
$command
)
{
if
(
$command
->
getDefinition
(
)
->
getClass
(
)
=== ImportExportProfileDefinition::
class
&&
$command
instanceof DeleteCommand
)
{
$ids
[
]
=
$command
->
getPrimaryKey
(
)
[
'id'
]
;
}
}
$filteredIds
=
$this
->
filterSystemDefaults
(
$ids
)
;
if
(
!
empty
(
$filteredIds
)
)
{
$event
->
getExceptions
(
)
->
add
(
new
DeleteDefaultProfileException
(
$filteredIds
)
)
;
}
}
private
function
filterSystemDefaults
(
array
$ids
)
: array
{
if
(
empty
(
$ids
)
)
{
return
[
]
;
}