You are here

function xmlsitemap_language_load in XML sitemap 8

Same name and namespace in other branches
  1. 6.2 xmlsitemap.module \xmlsitemap_language_load()
  2. 7.2 xmlsitemap.module \xmlsitemap_language_load()
  3. 2.x xmlsitemap.module \xmlsitemap_language_load()

Load a language object by its language code.

@todo Remove when https://www.drupal.org/node/660736 is fixed in Drupal core.

Parameters

string $language: A language code. If not provided the default language will be returned.

Return value

\Drupal\core\Language\LanguageInterface A language object.

3 calls to xmlsitemap_language_load()
content_translation_xmlsitemap_element_alter in ./xmlsitemap.module
Implements hook_xmlsitemap_element_alter() for content_translation module.
language_xmlsitemap_context_url_options in ./xmlsitemap.module
Implements hook_xmlsitemap_context_url_options() for language module.
XmlSitemapGenerator::generateChunk in src/XmlSitemapGenerator.php
Generates one chunk of the sitemap.

File

./xmlsitemap.module, line 1381
xmlsitemap XML sitemap

Code

function xmlsitemap_language_load($language = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
  $languages =& drupal_static(__FUNCTION__);
  if (!isset($languages)) {
    $languages = \Drupal::languageManager()
      ->getLanguages();
    $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = NULL;
  }
  return isset($languages[$language]) ? $languages[$language] : NULL;
}