function HelpController::helpMain
Same name in other branches
- 9 core/modules/help/src/Controller/HelpController.php \Drupal\help\Controller\HelpController::helpMain()
- 8.9.x core/modules/help/src/Controller/HelpController.php \Drupal\help\Controller\HelpController::helpMain()
- 10 core/modules/help/src/Controller/HelpController.php \Drupal\help\Controller\HelpController::helpMain()
Prints a page listing various types of help.
The page has sections defined by \Drupal\help\HelpSectionPluginInterface plugins.
Return value
array A render array for the help page.
1 string reference to 'HelpController::helpMain'
- 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 66
Class
- HelpController
- Controller routines for help routes.
Namespace
Drupal\help\ControllerCode
public function helpMain() {
$output = [];
// We are checking permissions, so add the user.permissions cache context.
$cacheability = new CacheableMetadata();
$cacheability->addCacheContexts([
'user.permissions',
]);
$plugins = $this->helpManager
->getDefinitions();
$cacheability->addCacheableDependency($this->helpManager);
foreach ($plugins as $plugin_id => $plugin_definition) {
// Check the provided permission.
if (!empty($plugin_definition['permission']) && !$this->currentUser()
->hasPermission($plugin_definition['permission'])) {
continue;
}
// Add the section to the page.
/** @var \Drupal\help\HelpSectionPluginInterface $plugin */
$plugin = $this->helpManager
->createInstance($plugin_id);
$this_output = [
'#theme' => 'help_section',
'#title' => $plugin->getTitle(),
'#description' => $plugin->getDescription(),
'#empty' => $this->t('There is currently nothing in this section.'),
'#links' => [],
'#weight' => $plugin_definition['weight'],
];
$links = $plugin->listTopics();
if (is_array($links) && count($links)) {
$this_output['#links'] = $links;
}
$cacheability->addCacheableDependency($plugin);
$output[$plugin_id] = $this_output;
}
$cacheability->applyTo($output);
return $output;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.