You are here

function language_xmlsitemap_element_alter in XML sitemap 8

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

Implements hook_xmlsitemap_element_alter() for language module.

File

./xmlsitemap.module, line 1868
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);
    }
  }
}