class SearchHelpHooks
Hook implementations for help.
Hierarchy
- class \Drupal\search_help\Hook\SearchHelpHooks
Expanded class hierarchy of SearchHelpHooks
File
-
core/
modules/ search/ modules/ search_help/ src/ Hook/ SearchHelpHooks.php, line 15
Namespace
Drupal\search_help\HookView source
class SearchHelpHooks {
public function __construct(#[Autowire(service: 'plugin.manager.search')] protected readonly SearchPluginManager $searchManager, #[Autowire(service: 'plugin.cache_clearer')] protected readonly CachedDiscoveryClearerInterface $pluginCacheClearer) {
}
/**
* Implements hook_modules_uninstalled().
*/
public function modulesUninstalled(array $modules) : void {
$this->searchUpdate($modules);
}
/**
* Implements hook_modules_installed().
*/
public function modulesInstalled(array $modules, $is_syncing) : void {
$this->searchUpdate();
}
/**
* Implements hook_themes_installed().
*
* Implements hook_themes_uninstalled().
*/
public function themesInstallOrUninstall(array $themes) : void {
$this->pluginCacheClearer
->clearCachedDefinitions();
$this->searchUpdate();
}
/**
* Implements hook_rebuild().
*/
public function rebuild() : void {
if ($this->searchManager
->hasDefinition('help_search')) {
$help_search = $this->searchManager
->createInstance('help_search');
$help_search->markForReindex();
}
}
/**
* Ensure that search is updated when extensions are installed or uninstalled.
*
* @param 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.
*/
protected function searchUpdate(array $extensions = []) : void {
// Early return if we're uninstalling this module.
if (in_array('search_help', $extensions)) {
return;
}
// Ensure that topics for extensions that have been uninstalled are removed
// and that the index state variable is updated.
$help_search = $this->searchManager
->createInstance('help_search');
$help_search->updateTopicList();
$help_search->updateIndexState();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.