/**
* @param PostFlushEventArgs $args
*/
public function postFlush(PostFlushEventArgs $args)
{
if ($this->isInProgress) {
return;
}
$this->initializeFromEventArgs($args);
if (count($this->queued) > 0) {
$toOutDate = [];
foreach ($this->queued as $customerIdentity => $groupedByEntityUpdates) {
foreach ($groupedByEntityUpdates as $data) {
/** @var Account $account */
$account = is_object($data['account']) ? $data['account'] : $this->em->getReference('OroCRMAccountBundle:Account', $data['account']);
/** @var Channel $channel */
$channel = is_object($data['channel']) ? $data['channel'] : $this->em->getReference('OroCRMChannelBundle:Channel', $data['channel']);
$entity = $this->createHistoryEntry($customerIdentity, $account, $channel);
$toOutDate[] = [$account, $channel, $entity];
$this->em->persist($entity);
}
}
$this->isInProgress = true;
$this->em->flush();
foreach (array_chunk($toOutDate, self::MAX_UPDATE_CHUNK_SIZE) as $chunks) {
$this->lifetimeRepo->massStatusUpdate($chunks);
}
$this->queued = [];
$this->isInProgress = false;
}
}