You are here

public function EntityUrlGenerator::getDataSets in Simple XML sitemap 8.2

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

@inheritdoc

Overrides UrlGeneratorBase::getDataSets

File

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

Class

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

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

public function getDataSets() {
  $data_sets = [];
  $sitemap_entity_types = $this->entityHelper
    ->getSupportedEntityTypes();
  foreach ($this->generator
    ->getBundleSettings() as $entity_type_name => $bundles) {
    if (isset($sitemap_entity_types[$entity_type_name])) {

      // Skip this entity type if another plugin is written to override its generation.
      foreach ($this->urlGeneratorManager
        ->getDefinitions() as $plugin) {
        if ($plugin['enabled'] && !empty($plugin['settings']['overrides_entity_type']) && $plugin['settings']['overrides_entity_type'] === $entity_type_name) {
          continue 2;
        }
      }
      foreach ($bundles as $bundle_name => $bundle_settings) {
        if ($bundle_settings['index']) {
          $data_sets[] = [
            'bundle_settings' => $bundle_settings,
            'bundle_name' => $bundle_name,
            'entity_type_name' => $entity_type_name,
            'keys' => $sitemap_entity_types[$entity_type_name]
              ->getKeys(),
          ];
        }
      }
    }
  }
  return $data_sets;
}