toString(); $module_handler = \Drupal::moduleHandler(); $locale_help = ($module_handler->moduleExists('locale')) ? Url::fromRoute('help.page', ['name' => 'locale'])->toString() : '#'; $search_help = ($module_handler->moduleExists('search')) ? Url::fromRoute('help.page', ['name' => 'search'])->toString() : '#'; $output = ''; $output .= '
' . t('The Help Topics module adds module- and theme-provided help topics to the module overviews from the core Help module. If the core Search module is enabled, these topics are also searchable. For more information, see the online documentation for the Help Topics module.', [':online' => 'https://www.drupal.org/documentation/modules/help_topics']) . '
'; $output .= '' . t('See the Help page for more topics.', [ ':help_page' => $help_home, ]) . '
'; } } /** * Implements hook_theme(). */ function help_topics_theme() { return [ 'help_topic' => [ 'variables' => [ 'body' => [], 'related' => [], ], ], ]; } /** * Implements hook_modules_uninstalled(). */ function help_topics_modules_uninstalled(array $modules) { _help_topics_search_update($modules); } /** * Implements hook_themes_uninstalled(). */ function help_topics_themes_uninstalled(array $themes) { _help_topics_search_update(); } /** * Implements hook_modules_installed(). */ function help_topics_modules_installed(array $modules, $is_syncing) { _help_topics_search_update(); } /** * Implements hook_themes_installed(). */ function help_topics_themes_installed(array $themes) { _help_topics_search_update(); } /** * 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. */ 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(); } }