public 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.
File
- core/modules/help/src/Controller/HelpController.php, line 63
Class
- HelpController
- Controller routines for help routes.
Namespace
Drupal\help\Controller
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 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' => [], ]; $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 ; } |
Please login to continue.