You are here

protected function EntityUrlGenerator::getBatchIterationElements in Simple XML sitemap 8.2

@inheritdoc

Overrides UrlGeneratorBase::getBatchIterationElements

File

src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGenerator.php, line 179

Class

EntityUrlGenerator
Class EntityUrlGenerator @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function getBatchIterationElements($entity_info) {
  $query = $this->entityTypeManager
    ->getStorage($entity_info['entity_type_name'])
    ->getQuery();
  if (!empty($entity_info['keys']['id'])) {
    $query
      ->sort($entity_info['keys']['id'], 'ASC');
  }
  if (!empty($entity_info['keys']['bundle'])) {
    $query
      ->condition($entity_info['keys']['bundle'], $entity_info['bundle_name']);
  }
  if (!empty($entity_info['keys']['status'])) {
    $query
      ->condition($entity_info['keys']['status'], 1);
  }
  if ($this
    ->needsInitialization()) {
    $count_query = clone $query;
    $this
      ->initializeBatch($count_query
      ->count()
      ->execute());
  }
  if ($this
    ->isBatch()) {
    $query
      ->range($this->context['sandbox']['progress'], $this->batchSettings['batch_process_limit']);
  }
  return $this->entityTypeManager
    ->getStorage($entity_info['entity_type_name'])
    ->loadMultiple($query
    ->execute());
}