You are here

protected function EntityMenuLinkContentUrlGenerator::getBatchIterationElements in Simple XML sitemap 8.2

@inheritdoc

Overrides UrlGeneratorBase::getBatchIterationElements

File

src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php, line 199

Class

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

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function getBatchIterationElements($menu_name) {

  // Retrieve the expanded tree.
  $tree = $this->menuLinkTree
    ->load($menu_name, new MenuTreeParameters());
  $tree = $this->menuLinkTree
    ->transform($tree, [
    [
      'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
    ],
  ]);
  foreach ($tree as $i => $item) {
    $this->elements[] = $item->link;
    if ($item->hasChildren) {
      $this
        ->getMenuChildrenRecursively($item);
    }
  }
  $this->elements = array_values($this->elements);
  if ($this
    ->needsInitialization()) {
    $this
      ->initializeBatch(count($this->elements));
  }
  return $this
    ->isBatch() ? array_slice($this->elements, $this->context['sandbox']['progress'], $this->batchSettings['batch_process_limit']) : $this->elements;
}