You are here

public function HelpController::helpPage in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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_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 113
Contains \Drupal\help\Controller\HelpController.

Class

HelpController
Controller routines for help routes.

Namespace

Drupal\help\Controller

Code

public function helpPage($name) {
  $build = array();
  if ($this
    ->moduleHandler()
    ->implementsHook($name, 'help')) {
    $module_name = $this
      ->moduleHandler()
      ->getName($name);
    $build['#title'] = $module_name;
    $temp = $this
      ->moduleHandler()
      ->invoke($name, 'help', array(
      "help.page.{$name}",
      $this->routeMatch,
    ));
    if (empty($temp)) {
      $build['top']['#markup'] = $this
        ->t('No help is available for module %module.', array(
        '%module' => $module_name,
      ));
    }
    else {
      $build['top']['#markup'] = $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, system_get_info('module', $name));
    if (!empty($admin_tasks)) {
      $links = array();
      foreach ($admin_tasks as $task) {
        $link['url'] = $task['url'];
        $link['title'] = $task['title'];
        $links[] = $link;
      }
      $build['links'] = array(
        '#theme' => 'links__help',
        '#heading' => array(
          'level' => 'h3',
          'text' => $this
            ->t('@module administration pages', array(
            '@module' => $module_name,
          )),
        ),
        '#links' => $links,
      );
    }
    return $build;
  }
  else {
    throw new NotFoundHttpException();
  }
}