diff --git a/core/modules/help/help.module b/core/modules/help/help.module index aac8636..31d6736 100644 --- a/core/modules/help/help.module +++ b/core/modules/help/help.module @@ -12,8 +12,7 @@ function help_menu() { $items['admin/help'] = array( 'title' => 'Help', 'description' => 'Reference for usage, configuration, and modules.', - 'page callback' => 'help_main', - 'access arguments' => array('access administration pages'), + 'route_name' => 'help_main', 'weight' => 9, 'file' => 'help.admin.inc', ); diff --git a/core/modules/help/help.routing.yml b/core/modules/help/help.routing.yml new file mode 100644 index 0000000..d4682ee --- /dev/null +++ b/core/modules/help/help.routing.yml @@ -0,0 +1,6 @@ +help_main: + pattern: 'admin/help' + defaults: + _content: '\Drupal\help\Controller\HelpController::helpMain' + requirements: + _permission: 'access administration pages' diff --git a/core/modules/help/lib/Drupal/help/Controller/HelpController.php b/core/modules/help/lib/Drupal/help/Controller/HelpController.php new file mode 100644 index 0000000..c020b51 --- /dev/null +++ b/core/modules/help/lib/Drupal/help/Controller/HelpController.php @@ -0,0 +1,83 @@ +moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static($container->get('module_handler')); + } + + /** + * Prints a page listing a glossary of Drupal terminology. + */ + public function helpMain() { + // Add CSS. + drupal_add_css(drupal_get_path('module', 'help') . '/help.css'); + $output = '

' . t('Help topics') . '

' . t('Help is available on the following items:') . '

' . $this->helpLinksAsList(); + return $output; + } + + /** + * Provides a formatted list of available help topics. + * + * @return + * A string containing the formatted list. + */ + private function helpLinksAsList() { + $empty_arg = drupal_help_arg(); + $module_info = system_rebuild_module_data(); + + $modules = array(); + foreach ($this->moduleHandler->getImplementations('help') as $module) { + if ($this->moduleHandler->invoke($module, 'help', array("admin/help#$module", $empty_arg))) { + $modules[$module] = $module_info[$module]->info['name']; + } + } + asort($modules); + + // Output pretty four-column list. + $count = count($modules); + $break = ceil($count / 4); + $output = '
'; + + return $output; + } +}