You are here

public function EntityMenuLinkContentUrlGenerator::getDataSets in Simple XML sitemap 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityMenuLinkContentUrlGenerator::getDataSets()
  2. 4.x src/Plugin/simple_sitemap/UrlGenerator/EntityMenuLinkContentUrlGenerator.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityMenuLinkContentUrlGenerator::getDataSets()

@inheritdoc

Overrides UrlGeneratorBase::getDataSets

File

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

Class

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

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

public function getDataSets() {
  $data_sets = [];
  $bundle_settings = $this->generator
    ->setVariants($this->sitemapVariant)
    ->getBundleSettings();
  if (!empty($bundle_settings['menu_link_content'])) {
    foreach ($bundle_settings['menu_link_content'] as $bundle_name => $bundle_settings) {
      if (!empty($bundle_settings['index'])) {

        // Retrieve the expanded tree.
        $tree = $this->menuLinkTree
          ->load($bundle_name, new MenuTreeParameters());
        $tree = $this->menuLinkTree
          ->transform($tree, [
          [
            'callable' => 'menu.default_tree_manipulators:generateIndexAndSort',
          ],
          [
            'callable' => 'menu.default_tree_manipulators:flatten',
          ],
        ]);
        foreach ($tree as $i => $item) {
          $data_sets[] = $item->link;
        }
      }
    }
  }
  return $data_sets;
}