You are here

protected function UrlGeneratorBase::addUrlVariants in Simple XML sitemap 8.2

Parameters

Url $url_object:

array $path_data:

1 call to UrlGeneratorBase::addUrlVariants()
UrlGeneratorBase::addUrl in src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php

File

src/Plugin/simple_sitemap/UrlGenerator/UrlGeneratorBase.php, line 225

Class

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

Namespace

Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator

Code

protected function addUrlVariants(array $path_data, Url $url_object) {
  if (!$url_object
    ->isRouted()) {

    // Not a routed URL, including only default variant.
    $alternate_urls = $this
      ->getAlternateUrlsForDefaultLanguage($url_object);
  }
  elseif ($this->batchSettings['skip_untranslated'] && ($entity = $this->entityHelper
    ->getEntityFromUrlObject($url_object)) instanceof ContentEntityBase) {
    $translation_languages = $entity
      ->getTranslationLanguages();
    if (isset($translation_languages[Language::LANGCODE_NOT_SPECIFIED]) || isset($translation_languages[Language::LANGCODE_NOT_APPLICABLE])) {

      // Content entity's language is unknown, including only default variant.
      $alternate_urls = $this
        ->getAlternateUrlsForDefaultLanguage($url_object);
    }
    else {

      // Including only translated variants of content entity.
      $alternate_urls = $this
        ->getAlternateUrlsForTranslatedLanguages($entity, $url_object);
    }
  }
  else {

    // Not a content entity or including all untranslated variants.
    $alternate_urls = $this
      ->getAlternateUrlsForAllLanguages($url_object);
  }
  foreach ($alternate_urls as $langcode => $url) {
    $this
      ->addBatchResult($path_data + [
      'langcode' => $langcode,
      'url' => $url,
      'alternate_urls' => $alternate_urls,
    ]);
  }
}