You are here

function xmlsitemap_engines_get_engine_info in XML sitemap 8

Same name and namespace in other branches
  1. 6.2 xmlsitemap_engines/xmlsitemap_engines.module \xmlsitemap_engines_get_engine_info()
  2. 7.2 xmlsitemap_engines/xmlsitemap_engines.module \xmlsitemap_engines_get_engine_info()
  3. 2.x xmlsitemap_engines/xmlsitemap_engines.module \xmlsitemap_engines_get_engine_info()

Returns information about supported search engines.

Parameters

string $engine: (optional) The engine to return information for. If omitted, information for all engines is returned.

Return value

string[] An array of supported search engines.

See also

hook_xmlsitemap_engines_info()

hook_xmlsitemap_engines_info_alter()

2 calls to xmlsitemap_engines_get_engine_info()
XmlSitemapEnginesSettingsForm::buildForm in xmlsitemap_engines/src/Form/XmlSitemapEnginesSettingsForm.php
Form constructor.
xmlsitemap_engines_submit_engines in xmlsitemap_engines/xmlsitemap_engines.module
Submit the sitemaps to all the specified search engines.

File

xmlsitemap_engines/xmlsitemap_engines.module, line 172
Main file for the XML sitemap engines.

Code

function xmlsitemap_engines_get_engine_info($engine = NULL) {
  $language = \Drupal::languageManager()
    ->getCurrentLanguage();
  $engines =& drupal_static(__FUNCTION__);
  if (!isset($engines)) {
    if ($cached = \Drupal::cache()
      ->get('xmlsitemap:engines:' . $language
      ->getId())) {
      $engines = $cached->data;
    }
    else {

      // Fetch the results of all hook_xmlsitemap_engine_info() implementations.
      $engines = \Drupal::moduleHandler()
        ->invokeAll('xmlsitemap_engine_info');

      // Allow other modules to alter the engine info.
      \Drupal::moduleHandler()
        ->alter('xmlsitemap_engine_info', $engines);

      // Cache by language since engine names are translated.
      \Drupal::cache()
        ->set('xmlsitemap:engines:' . $language
        ->getId(), $engines, Cache::PERMANENT, [
        'xmlsitemap',
      ]);
    }
  }
  if (isset($engine)) {
    return isset($engines[$engine]) ? $engines[$engine] : NULL;
  }
  else {
    return $engines;
  }
}