private function manageBatch(array $batch, $max = 0)
    {
        if (count($batch) >= $max) {
            $this->entityManager->flush();
            $batch = [];
        }

        return $batch;
    }