' . t('Getting Started') . ''; $output .= '
' . t('Follow these steps to set up and start using your website:') . '
'; $output .= '' . t('For more information, refer to the help listed on this page or to the online documentation and support pages at drupal.org.', [':docs' => 'https://www.drupal.org/documentation', ':support' => 'https://www.drupal.org/support', ':drupal' => 'https://www.drupal.org']) . '
'; return ['#markup' => $output]; case 'help.page.help': $help_home = Url::fromRoute('help.main')->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 = '' . t('The Help module generates Help topics and reference pages to guide you through the use and configuration of modules, and provides a Help block with page-level help. The reference pages are a starting point for Drupal.org online documentation pages that contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the online documentation for the Help module.', [':help' => 'https://www.drupal.org/documentation/modules/help/', ':handbook' => 'https://www.drupal.org/documentation', ':help-page' => Url::fromRoute('help.main')->toString()]) . '
'; $output .= '' . t('Help topics provided by modules and themes are also part of the Help module. If the core Search module is installed, these topics are searchable. For more information, see the online documentation, Help Topic Standards.', [':online' => 'https://www.drupal.org/docs/develop/managing-a-drupalorg-theme-module-or-distribution-project/documenting-your-project/help-topic-standards']) . '
'; $output .= '' . t('See the Help page for more topics.', [ ':help_page' => $help_home, ]) . '
'; } } /** * Implements hook_theme(). */ function help_theme($existing, $type, $theme, $path) { return [ 'help_section' => [ 'variables' => [ 'title' => NULL, 'description' => NULL, 'links' => NULL, 'empty' => NULL, ], ], 'help_topic' => [ 'variables' => [ 'body' => [], 'related' => [], ], ], ]; } /** * Implements hook_preprocess_HOOK() for block templates. */ function help_preprocess_block(&$variables) { if ($variables['plugin_id'] == 'help_block') { $variables['attributes']['role'] = 'complementary'; } } /** * Implements hook_block_view_BASE_BLOCK_ID_alter(). */ function help_block_view_help_block_alter(array &$build, BlockPluginInterface $block) { // Assume that most users do not need or want to perform contextual actions on // the help block, so don't needlessly draw attention to it. unset($build['#contextual_links']); } /** * Implements hook_modules_uninstalled(). */ function help_modules_uninstalled(array $modules) { _help_search_update($modules); } /** * Implements hook_themes_uninstalled(). */ function help_themes_uninstalled(array $themes) { \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); _help_search_update(); } /** * Implements hook_modules_installed(). */ function help_modules_installed(array $modules, $is_syncing) { _help_search_update(); } /** * Implements hook_themes_installed(). */ function help_themes_installed(array $themes) { \Drupal::service('plugin.cache_clearer')->clearCachedDefinitions(); _help_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_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', $extensions)) { return; } // Ensure that topics for extensions that have been uninstalled are removed // and that the index state variable is updated. $help_search = \Drupal::service('plugin.manager.search')->createInstance('help_search'); $help_search->updateTopicList(); $help_search->updateIndexState(); }