You are here

function xmlsitemap_get_context_info in XML sitemap 8

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

Gets info about a context.

Parameters

string $context: The context.

bool $reset: If TRUE, resets context info.

Return value

array Array with info.

Related topics

2 calls to xmlsitemap_get_context_info()
XmlSitemapForm::form in src/Form/XmlSitemapForm.php
Gets the actual form array to be built.
XmlSitemapStorage::doLoadMultiple in src/XmlSitemapStorage.php
Performs storage-specific loading of entities.

File

./xmlsitemap.module, line 1408
xmlsitemap XML sitemap

Code

function xmlsitemap_get_context_info($context = NULL, $reset = FALSE) {
  $language = \Drupal::languageManager()
    ->getCurrentLanguage();
  $info =& drupal_static(__FUNCTION__);
  if ($reset) {
    $info = NULL;
  }
  elseif ($cached = \Drupal::cache()
    ->get('xmlsitemap:context_info:' . $language
    ->getId())) {
    $info = $cached->data;
  }
  if (!isset($info)) {
    $info = \Drupal::moduleHandler()
      ->invokeAll('xmlsitemap_context_info');
    \Drupal::moduleHandler()
      ->alter('xmlsitemap_context_info', $info);
    ksort($info);

    // Cache by language since this info contains translated strings.
    \Drupal::cache()
      ->set('xmlsitemap:context_info:' . $language
      ->getId(), $info, Cache::PERMANENT, [
      'xmlsitemap',
    ]);
  }
  if (isset($context)) {
    return isset($info[$context]) ? $info[$context] : NULL;
  }
  return $info;
}