function SearchHelpHooks::help
Same name and namespace in other branches
- 11.x core/modules/search/modules/search_help/src/Hook/SearchHelpHooks.php \Drupal\search_help\Hook\SearchHelpHooks::help()
Implements hook_help() on behalf of the help module.
\Drupal\help\Controller\HelpController::helpPage() only invokes the implementation of the module whose page is requested, so the section about help search has to be part of the help module implementation. This method replaces it: it returns the original output and appends the section.
Attributes
File
-
core/
modules/ search/ modules/ search_help/ src/ Hook/ SearchHelpHooks.php, line 40
Class
- SearchHelpHooks
- Hook implementations for help.
Namespace
Drupal\search_help\HookCode
public function help($route_name, RouteMatchInterface $route_match) : string|array|null {
$output = $this->helpHooks
->help($route_name, $route_match);
if ($route_name !== 'help.page.help') {
return $output;
}
$search_help = Url::fromRoute('help.page', [
'name' => 'search',
])->toString();
// Remove that trailing close description list tag.
$output['#markup'] = rtrim($output['#markup'], "</dl>");
$section = '<dt>' . $this->t('Configuring help search') . '</dt>';
$section .= '<dd>' . $this->t('To search help, configure a search page and add a search block to the Help page or another administrative page. (A search page is provided automatically, and if you use the core Administrative theme, a help search block is shown on the main Help page.) Then users with search permissions, and permission to view help, will be able to search help. See the <a href=":search_help">Search module help page</a> for more information.', [
':search_help' => $search_help,
]) . '</dd>';
$section .= '</dl>';
$output['#markup'] .= $section;
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.