Commit 5a2a234c authored by andrei.dincu's avatar andrei.dincu
Browse files

Issue #2249723 by andrei.dincu: Convert to D8 version...

Issue #2249723 by andrei.dincu: Convert to D8 version xmlsitemap_get_context_info() and xmlsitemap_get_current_context()
parent 1d68c651
...@@ -1578,12 +1578,12 @@ function xmlsitemap_get_changefreq_options() { ...@@ -1578,12 +1578,12 @@ function xmlsitemap_get_changefreq_options() {
* @return * @return
* A language object. * A language object.
*/ */
function xmlsitemap_language_load($language = LANGUAGE_NONE) { function xmlsitemap_language_load($language = LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$languages = &drupal_static(__FUNCTION__); $languages = &drupal_static(__FUNCTION__);
if (!isset($languages)) { if (!isset($languages)) {
$languages = language_list(); $languages = \Drupal::languageManager()->getLanguages();
$languages[LANGUAGE_NONE] = NULL; $languages[LanguageInterface::LANGCODE_NOT_SPECIFIED] = NULL;
} }
return isset($languages[$language]) ? $languages[$language] : NULL; return isset($languages[$language]) ? $languages[$language] : NULL;
...@@ -1594,22 +1594,22 @@ function xmlsitemap_language_load($language = LANGUAGE_NONE) { ...@@ -1594,22 +1594,22 @@ function xmlsitemap_language_load($language = LANGUAGE_NONE) {
* @{ * @{
*/ */
function xmlsitemap_get_context_info($context = NULL, $reset = FALSE) { function xmlsitemap_get_context_info($context = NULL, $reset = FALSE) {
global $language; $language = \Drupal::languageManager()->getCurrentLanguage();
$info = &drupal_static(__FUNCTION__); $info = &drupal_static(__FUNCTION__);
if ($reset) { if ($reset) {
$info = NULL; $info = NULL;
} }
elseif ($cached = \Drupal::cache()->get('xmlsitemap:context_info:' . $language->language)) { elseif ($cached = \Drupal::cache()->get('xmlsitemap:context_info:' . $language->getId())) {
$info = $cached->data; $info = $cached->data;
} }
if (!isset($info)) { if (!isset($info)) {
$info = \Drupal::moduleHandler()->invokeAll('xmlsitemap_context_info'); $info = \Drupal::moduleHandler()->invokeAll('xmlsitemap_context_info');
drupal_alter('xmlsitemap_context_info', $info); \Drupal::moduleHandler()->alter('xmlsitemap_context_info', $info);
ksort($info); ksort($info);
// Cache by language since this info contains translated strings. // Cache by language since this info contains translated strings.
\Drupal::cache()->set('xmlsitemap:context_info:' . $language->language, $info); \Drupal::cache()->set('xmlsitemap:context_info:' . $language->getId(), $info);
} }
if (isset($context)) { if (isset($context)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment