Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getAssociationFields example
foreach
(
$this
->
getForeignKeyFields
(
$definition
)
as
$field
)
{
if
(
$command
->
hasField
(
$field
->
getStorageName
(
)
)
)
{
$command
->
requestChangeSet
(
)
;
}
}
}
}
public
function
onEntityWritten
(
EntityWrittenContainerEvent
$event
)
: void
{
$associationFields
=
$this
->
getAssociationFields
(
)
;
$ruleIds
=
[
]
;
foreach
(
$event
->
getEvents
(
)
??
[
]
as
$nestedEvent
)
{
if
(
!
$nestedEvent
instanceof EntityWrittenEvent
)
{
continue
;
}
$definition
=
$this
->
getAssociationDefinitionByEntity
(
$associationFields
,
$nestedEvent
->
getEntityName
(
)
)
;
if
(
!
$definition
)
{
continue
;
}
new
NotFilter
(
'AND',
[
new
EqualsFilter
(
'mediaFolderId',
$folder
->
getId
(
)
)
,
]
)
,
new
EqualsFilter
(
'mediaFolderId', null
)
,
]
)
)
;
continue
;
}
foreach
(
$defaultFolder
->
getAssociationFields
(
)
as
$associationField
)
{
$criteria
->
addFilter
(
new
EqualsFilter
(
"media.{
$associationField
}
.id", null
)
)
;
}
}
}
$extension
=
$context
->
getExtension
(
self::RESTRICT_DEFAULT_FOLDER_ENTITIES_EXTENSION
)
;
if
(
$extension
instanceof ArrayStruct
)
{
$criteria
->
addFilter
(
new
EqualsAnyFilter
(
'media.mediaFolder.defaultFolder.entity',
$extension
->
all
(
)
)
)
;