public static function SitemapGeneratorBase::isMultilingualSitemap in Simple XML sitemap 8.3
Determines if the sitemap is to be a multilingual sitemap based on several factors.
A hreflang/multilingual sitemap is only wanted if there are indexable languages available and if there is a language negotiation method enabled that is based on URL discovery. Any other language negotiation methods should be irrelevant, as a sitemap can only use URLs to guide to the correct language.
Return value
bool
See also
https://www.drupal.org/project/simple_sitemap/issues/3154570#comment-137...
2 calls to SitemapGeneratorBase::isMultilingualSitemap()
- DefaultSitemapGenerator::isHreflangSitemap in src/
Plugin/ simple_sitemap/ SitemapGenerator/ DefaultSitemapGenerator.php - Checks if sitemap is hreflang compliant.
- EntityUrlGeneratorBase::__construct in src/
Plugin/ simple_sitemap/ UrlGenerator/ EntityUrlGeneratorBase.php - UrlGeneratorBase constructor.
File
- src/
Plugin/ simple_sitemap/ SitemapGenerator/ SitemapGeneratorBase.php, line 362
Class
- SitemapGeneratorBase
- Class SitemapGeneratorBase @package Drupal\simple_sitemap\Plugin\simple_sitemap\UrlGenerator
Namespace
Drupal\simple_sitemap\Plugin\simple_sitemap\SitemapGeneratorCode
public static function isMultilingualSitemap() {
if (!\Drupal::moduleHandler()
->moduleExists('language')) {
return FALSE;
}
/** @var \Drupal\language\LanguageNegotiatorInterface $language_negotiator */
$language_negotiator = \Drupal::service('language_negotiator');
$url_negotiation_method_enabled = FALSE;
foreach ($language_negotiator
->getNegotiationMethods(LanguageInterface::TYPE_URL) as $method) {
if ($language_negotiator
->isNegotiationMethodEnabled($method['id'])) {
$url_negotiation_method_enabled = TRUE;
break;
}
}
$has_multiple_indexable_languages = count(array_diff_key(\Drupal::languageManager()
->getLanguages(), \Drupal::service('simple_sitemap.generator')
->getSetting('excluded_languages', []))) > 1;
return $url_negotiation_method_enabled && $has_multiple_indexable_languages;
}