private function forEachChunk(ObjectManager $objectManager, array $entities, $operation)
    {
        $batch = [];
        foreach (array_chunk($entities, $this->configuration['batchSize']) as $chunk) {
            $searchableEntitiesChunk = [];
            foreach ($chunk as $entity) {
                $entityClassName = ClassUtils::getClass($entity);

                $searchableEntitiesChunk[] = new SearchableEntity(
                    $this->getFullIndexName($entityClassName),
                    $entity,
                    $objectManager->getClassMetadata($entityClassName),
                    $this->normalizer,
                    ['useSerializerGroup' => $this->canUseSerializerGroup($entityClassName)]
                );
            }

            $batch[] = $operation($searchableEntitiesChunk);
        }

        return $this->formatBatchResponse($batch);
    }
private function forEachChunk(ObjectManager $objectManager, array $entities, $operation)
    {
        $batch = [];
        foreach (array_chunk($entities, $this->configuration['batchSize']) as $chunk) {
            $searchableEntitiesChunk = [];
            foreach ($chunk as $entity) {
                $entityClassName = ClassUtils::getClass($entity);

                $searchableEntitiesChunk[] = new SearchableEntity(
                    $this->getFullIndexName($entityClassName),
                    $entity,
                    $objectManager->getClassMetadata($entityClassName),
                    $this->normalizer,
                    ['useSerializerGroup' => $this->canUseSerializerGroup($entityClassName)]
                );
            }

            $batch[] = $operation($searchableEntitiesChunk);
        }

        return $this->formatBatchResponse($batch);
    }
private function forEachChunk ( ObjectManager $ objectManager , array $ entities , $ operation ) { $ batch = [ ] ; foreach ( array_chunk ( $ entities , $ this -> configuration [ 'batchSize' ] ) as $ chunk ) { $ searchableEntitiesChunk = [ ] ; foreach ( $ chunk as $ entity ) { $ entityClassName = ClassUtils :: getClass ( $ entity ) ; $ searchableEntitiesChunk [ ] = new SearchableEntity ( $ this -> getFullIndexName ( $ entityClassName ) , $ entity , $ objectManager -> getClassMetadata ( $ entityClassName ) , $ this -> normalizer , [ 'useSerializerGroup' => $ this -> canUseSerializerGroup ( $ entityClassName ) ] ) ; } $ batch [ ] = $ operation ( $ searchableEntitiesChunk ) ; } return $ this -> formatBatchResponse ( $ batch ) ; }
For each chunk performs the provided operation.

@param  \Doctrine\Common\Persistence\ObjectManager $objectManager
@param  array $entities
@param  callable $operation
@return array
For each chunk performs the provided operation .