Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getOnlyEntities example
public
function
iterate
(
AdminIndexingBehavior
$indexingBehavior
)
: void
{
if
(
!
$this
->adminEsHelper->
getEnabled
(
)
)
{
return
;
}
/** @var array<string> $entities */
$entities
=
array_keys
(
$this
->indexer
)
;
if
(
$indexingBehavior
->
getOnlyEntities
(
)
)
{
$entities
=
array_intersect
(
$entities
,
$indexingBehavior
->
getOnlyEntities
(
)
)
;
}
elseif
(
$indexingBehavior
->
getSkipEntities
(
)
)
{
$entities
=
array_diff
(
$entities
,
$indexingBehavior
->
getSkipEntities
(
)
)
;
}
$indices
=
$this
->
createIndices
(
$entities
)
;
foreach
(
$entities
as
$entityName
)
{
$indexer
=
$this
->
getIndexer
(
$entityName
)
;
$iterator
=
$indexer
->
getIterator
(
)
;
return
[
RefreshIndexEvent::
class
=>
'handled',
]
;
}
public
function
handled
(
RefreshIndexEvent
$event
)
: void
{
$this
->registry->
iterate
(
new
AdminIndexingBehavior
(
$event
->
getNoQueue
(
)
,
$event
->
getSkipEntities
(
)
,
$event
->
getOnlyEntities
(
)
)
)
;
}
}