private function rebuildRecords($records, $batch_size)
{
$count = 0;
/** @var OrmProxyInterface $record */
foreach ($records as $record) {
$this->entity_manager->persist($record);
if (++$count == $batch_size) {
$this->entity_manager->flush();
$count = 0;
}
}
if ($count) {
$this->entity_manager->flush();
}
}