public function HelpController::helpPage in Drupal 9
Same name and namespace in other branches
- 8 core/modules/help/src/Controller/HelpController.php \Drupal\help\Controller\HelpController::helpPage()
- 10 core/modules/help/src/Controller/HelpController.php \Drupal\help\Controller\HelpController::helpPage()
Prints a page listing general help for a module.
Parameters
string $name: A module name to display a help page for.
Return value
array A render array as expected by \Drupal\Core\Render\RendererInterface::render().
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException
1 string reference to 'HelpController::helpPage'
- help.routing.yml in core/
modules/ help/ help.routing.yml - core/modules/help/help.routing.yml
File
- core/
modules/ help/ src/ Controller/ HelpController.php, line 129
Class
- HelpController
- Controller routines for help routes.
Namespace
Drupal\help\ControllerCode
public function helpPage($name) {
$build = [];
if ($this
->moduleHandler()
->implementsHook($name, 'help')) {
$module_name = $this
->moduleHandler()
->getName($name);
$build['#title'] = $module_name;
$info = $this->moduleExtensionList
->getExtensionInfo($name);
if ($info[ExtensionLifecycle::LIFECYCLE_IDENTIFIER] === ExtensionLifecycle::EXPERIMENTAL) {
$this
->messenger()
->addWarning($this
->t('This module is experimental. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', [
':url' => 'https://www.drupal.org/core/experimental',
]));
}
$temp = $this
->moduleHandler()
->invoke($name, 'help', [
"help.page.{$name}",
$this->routeMatch,
]);
if (empty($temp)) {
$build['top'] = [
'#markup' => $this
->t('No help is available for module %module.', [
'%module' => $module_name,
]),
];
}
else {
if (!is_array($temp)) {
$temp = [
'#markup' => $temp,
];
}
$build['top'] = $temp;
}
// Only print list of administration pages if the module in question has
// any such pages associated with it.
$admin_tasks = system_get_module_admin_tasks($name, $info);
if (!empty($admin_tasks)) {
$links = [];
foreach ($admin_tasks as $task) {
$link['url'] = $task['url'];
$link['title'] = $task['title'];
$links[] = $link;
}
$build['links'] = [
'#theme' => 'links__help',
'#heading' => [
'level' => 'h3',
'text' => $this
->t('@module administration pages', [
'@module' => $module_name,
]),
],
'#links' => $links,
];
}
return $build;
}
else {
throw new NotFoundHttpException();
}
}