Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getScheduledEntityDeletions example
return
[
Events::onFlush, Events::postFlush
]
;
}
public
function
onFlush
(
OnFlushEventArgs
$eventArgs
)
{
$em
=
$eventArgs
->
getEntityManager
(
)
;
$uow
=
$em
->
getUnitOfWork
(
)
;
// Entity deletions
foreach
(
$uow
->
getScheduledEntityDeletions
(
)
as
$entity
)
{
$backlog
=
$this
->
getDeleteBacklog
(
$entity
)
;
if
(
!
$backlog
)
{
continue
;
}
$this
->queue
[
]
=
$backlog
;
}
// Entity Insertions
foreach
(
$uow
->
getScheduledEntityInsertions
(
)
as
$entity
)
{
$this
->inserts
[
]
=
$entity
;
}
if
(
$this
->disabledForNextFlush
)
{
return
;
}
$em
=
$eventArgs
->
getEntityManager
(
)
;
$uow
=
$em
->
getUnitOfWork
(
)
;
$this
->pendingAddAssignments =
[
]
;
$this
->pendingRemoveAssignments =
[
]
;
// Entity deletions
foreach
(
$uow
->
getScheduledEntityDeletions
(
)
as
$entity
)
{
if
(
$entity
instanceof Category
)
{
$this
->
backlogRemoveCategory
(
$entity
->
getId
(
)
)
;
}
if
(
$entity
instanceof Article
)
{
$this
->
backlogRemoveArticle
(
$entity
->
getId
(
)
)
;
}
}
// Entity Insertions
foreach
(
$uow
->
getScheduledEntityInsertions
(
)
as
$category
)
{
return
$backlog
->entity . '_' .
$backlog
->entity_id;
}
private
function
trace
(
OnFlushEventArgs
$eventArgs
)
: void
{
$em
=
$eventArgs
->
getEntityManager
(
)
;
$uow
=
$em
->
getUnitOfWork
(
)
;
$queue
=
[
]
;
// Entity deletions
foreach
(
$uow
->
getScheduledEntityDeletions
(
)
as
$entity
)
{
$backlog
=
$this
->
getBacklog
(
$entity
)
;
if
(
!
$backlog
)
{
continue
;
}
$queue
[
$this
->
getBacklogKey
(
$backlog
)
]
=
$backlog
;
}
// Entity Insertions
foreach
(
$uow
->
getScheduledEntityInsertions
(
)
as
$entity
)
{
$backlog
=
$this
->
getBacklog
(
$entity
)
;
if
(
!
$backlog
||
$backlog
->entity_id === null
)
{