You are here

function _help_topics_search_update in Drupal 9

Ensure that search is updated when extensions are installed or uninstalled.

Parameters

string[] $extensions: (optional) If modules are being uninstalled, the names of the modules being uninstalled. For themes being installed/uninstalled, or modules being installed, omit this parameter.

4 calls to _help_topics_search_update()
help_topics_modules_installed in core/modules/help_topics/help_topics.module
Implements hook_modules_installed().
help_topics_modules_uninstalled in core/modules/help_topics/help_topics.module
Implements hook_modules_uninstalled().
help_topics_themes_installed in core/modules/help_topics/help_topics.module
Implements hook_themes_installed().
help_topics_themes_uninstalled in core/modules/help_topics/help_topics.module
Implements hook_themes_uninstalled().

File

core/modules/help_topics/help_topics.module, line 95
Displays help topics provided by modules and themes.

Code

function _help_topics_search_update(array $extensions = []) : void {

  // Early return if search is not installed or if we're uninstalling this
  // module.
  if (!\Drupal::hasService('plugin.manager.search') || in_array('help_topics', $extensions)) {
    return;
  }
  $search_plugin_manager = \Drupal::service('plugin.manager.search');
  if ($search_plugin_manager
    ->hasDefinition('help_search')) {

    // Ensure that topics for extensions that have been uninstalled are removed
    // and that the index state variable is updated.
    $help_search = $search_plugin_manager
      ->createInstance('help_search');
    $help_search
      ->updateTopicList();
    $help_search
      ->updateIndexState();
  }
}