You are here

public function HelpSectionManager::clearCachedDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/help_topics/src/HelpSectionManager.php \Drupal\help_topics\HelpSectionManager::clearCachedDefinitions()

Clears static and persistent plugin definition caches.

Don't resort to calling \Drupal::cache()->delete() and friends to make Drupal detect new or updated plugin definitions. Always use this method on the appropriate plugin type's plugin manager!

Overrides DefaultPluginManager::clearCachedDefinitions

File

core/modules/help_topics/src/HelpSectionManager.php, line 38

Class

HelpSectionManager
Decorates the Help Section plugin manager to provide help topic search.

Namespace

Drupal\help_topics

Code

public function clearCachedDefinitions() {
  parent::clearCachedDefinitions();
  if ($this->searchManager && $this->searchManager
    ->hasDefinition('help_search') && $this->moduleHandler
    ->moduleExists('help_topics')) {

    // Rebuild the index on cache clear so that new help topics are indexed
    // and any changes due to help topics edits or translation changes are
    // picked up.
    $help_search = $this->searchManager
      ->createInstance('help_search');
    $help_search
      ->markForReindex();
  }
}