Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
ProgressStartedEvent example
$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
(
)
;
$this
->dispatcher->
dispatch
(
new
ProgressStartedEvent
(
$indexer
->
getName
(
)
,
$iterator
->
fetchCount
(
)
)
)
;
while
(
$ids
=
$iterator
->
fetch
(
)
)
{
$ids
=
array_values
(
$ids
)
;
// we provide no queue when the data is sent by the admin
if
(
$indexingBehavior
->
getNoQueue
(
)
)
{
$this
->
__invoke
(
new
AdminSearchIndexingMessage
(
$indexer
->
getEntity
(
)
,
$indexer
->
getName
(
)
,
$indices
,
$ids
)
)
;
}
else
{
$this
->queue->
dispatch
(
new
AdminSearchIndexingMessage
(
$indexer
->
getEntity
(
)
,
$indexer
->
getName
(
)
,
$indices
,
$ids
)
)
;
}
foreach
(
$this
->indexer
as
$indexer
)
{
if
(
\
in_array
(
$indexer
->
getName
(
)
,
$skip
, true
)
)
{
continue
;
}
if
(
\
count
(
$only
)
> 0 && !\
in_array
(
$indexer
->
getName
(
)
,
$only
, true
)
)
{
continue
;
}
$offset
= null;
$this
->dispatcher->
dispatch
(
new
ProgressStartedEvent
(
$indexer
->
getName
(
)
,
$indexer
->
getTotal
(
)
)
)
;
while
(
$message
=
$indexer
->
iterate
(
$offset
)
)
{
$message
->
setIndexer
(
$indexer
->
getName
(
)
)
;
$message
->
addSkip
(
...
$skip
)
;
$this
->
sendOrHandle
(
$message
,
$useQueue
)
;
$offset
=
$message
->
getOffset
(
)
;
try
{
$count
= \
is_array
(
$message
->
getData
(
)
)
? \
count
(
$message
->
getData
(
)
)
: 1;