You are here

function language_xmlsitemap_element_alter in XML sitemap 2.x

Same name and namespace in other branches
  1. 8 xmlsitemap.module \language_xmlsitemap_element_alter()

Implements hook_xmlsitemap_element_alter() for language module.

File

./xmlsitemap.module, line 1828
xmlsitemap XML sitemap

Code

function language_xmlsitemap_element_alter(array &$element, array $link, XmlSitemapInterface $sitemap) {

  // Add alternate links for each language for generic links.
  if ($link['langcode'] === LanguageInterface::LANGCODE_NOT_SPECIFIED) {
    $languages = \Drupal::languageManager()
      ->getLanguages();
    unset($languages[$sitemap->context['language']]);
    foreach ($languages as $language) {
      _xmlsitemap_element_add_alternate_lang($element, $link['loc'], $language, $sitemap);
    }
  }
}