protected function EntityUrlGeneratorBase::getUrlVariants in Simple XML sitemap 4.x
Same name and namespace in other branches
- 8.3 src/Plugin/simple_sitemap/UrlGenerator/EntityUrlGeneratorBase.php \Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator\EntityUrlGeneratorBase::getUrlVariants()
Parameters
array $path_data:
\Drupal\Core\Url $url_object:
Return value
array
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
2 calls to EntityUrlGeneratorBase::getUrlVariants()
- EntityUrlGenerator::generate in src/
Plugin/ simple_sitemap/ UrlGenerator/ EntityUrlGenerator.php - @inheritdoc
- EntityUrlGeneratorBase::generate in src/
Plugin/ simple_sitemap/ UrlGenerator/ EntityUrlGeneratorBase.php
File
- src/
Plugin/ simple_sitemap/ UrlGenerator/ EntityUrlGeneratorBase.php, line 98
Class
- EntityUrlGeneratorBase
- Class EntityUrlGeneratorBase
Namespace
Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGeneratorCode
protected function getUrlVariants(array $path_data, Url $url_object) : array {
$url_variants = [];
if (!$this->sitemapVariant
->isMultilingual() || !$url_object
->isRouted()) {
// Not a routed URL or URL language negotiation disabled: Including only default variant.
$alternate_urls = $this
->getAlternateUrlsForDefaultLanguage($url_object);
}
elseif ($this->settings
->get('skip_untranslated') && ($entity = $this->entityHelper
->getEntityFromUrlObject($url_object)) instanceof ContentEntityInterface) {
/** @var ContentEntityInterface $entity */
$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) {
$url_variants[] = $path_data + [
'langcode' => $langcode,
'url' => $url,
'alternate_urls' => $alternate_urls,
];
}
return $url_variants;
}