You are here

public function EntityUrlGenerator::generate in Simple XML sitemap 8.3

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

@inheritdoc

Overrides EntityUrlGeneratorBase::generate

File

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

Class

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

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

public function generate($data_set) {
  $path_data_sets = $this
    ->processDataSet($data_set);
  $url_variant_sets = [];
  foreach ($path_data_sets as $key => $path_data) {
    if (isset($path_data['url']) && $path_data['url'] instanceof Url) {
      $url_object = $path_data['url'];
      unset($path_data['url']);
      $url_variant_sets[] = $this
        ->getUrlVariants($path_data, $url_object);
    }
  }

  // Make sure to clear entity memory cache so it does not build up resulting
  // in a constant increase of memory.
  // See https://www.drupal.org/project/simple_sitemap/issues/3170261 and
  // https://www.drupal.org/project/simple_sitemap/issues/3202233
  if ($this->entityTypeManager
    ->getDefinition($data_set['entity_type'])
    ->isStaticallyCacheable()) {
    $this->entityMemoryCache
      ->deleteAll();
  }
  return array_merge([], ...$url_variant_sets);
}