Skip to content

Commit

Permalink
fix: reset the dispatch flag in the event subscribe on clear event
Browse files Browse the repository at this point in the history
  • Loading branch information
delyriand committed Sep 20, 2022
1 parent bada6a8 commit f4a7ff3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/EventSubscriber/ReindexProductEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public function getSubscribedEvents()
return [
Events::onFlush => 'onFlush',
Events::postFlush => 'postFlush',
Events::onClear => 'onClear',
];
}

Expand All @@ -82,7 +83,7 @@ public function postFlush(PostFlushEventArgs $args): void
if (!$this->automaticReindexManager->shouldBeAutomaticallyReindex()) {
return;
}

$unitOfWork = $args->getEntityManager()->getUnitOfWork();
$this->manageUnitOfWork($unitOfWork);

Expand All @@ -102,6 +103,11 @@ public function postFlush(PostFlushEventArgs $args): void
}
}

public function onClear(): void
{
$this->dispatched = false;
}

private function onFlushEntities(array $entities, string $type = 'insertionsOrUpdate'): void
{
foreach ($entities as $entity) {
Expand Down

0 comments on commit f4a7ff3

Please sign in to comment.