You are here

protected function HelpController::helpLinksAsList 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::helpLinksAsList()

Provides a formatted list of available help topics.

Return value

string A string containing the formatted list.

1 call to HelpController::helpLinksAsList()
HelpController::helpMain in core/modules/help/src/Controller/HelpController.php
Prints a page listing a glossary of Drupal terminology.

File

core/modules/help/src/Controller/HelpController.php, line 67
Contains \Drupal\help\Controller\HelpController.

Class

HelpController
Controller routines for help routes.

Namespace

Drupal\help\Controller

Code

protected function helpLinksAsList() {
  $modules = array();
  foreach ($this
    ->moduleHandler()
    ->getImplementations('help') as $module) {
    $modules[$module] = $this->moduleHandler
      ->getName($module);
  }
  asort($modules);

  // Output pretty four-column list.
  $count = count($modules);
  $break = ceil($count / 4);
  $column = array(
    '#type' => 'container',
    'links' => array(
      '#theme' => 'item_list',
    ),
    '#attributes' => array(
      'class' => array(
        'layout-column',
        'layout-column--quarter',
      ),
    ),
  );
  $output = array(
    '#prefix' => '<div class="clearfix">',
    '#suffix' => '</div>',
    0 => $column,
  );
  $i = 0;
  $current_column = 0;
  foreach ($modules as $module => $name) {
    $output[$current_column]['links']['#items'][] = $this
      ->l($name, new Url('help.page', array(
      'name' => $module,
    )));
    if (($i + 1) % $break == 0 && $i + 1 != $count) {
      $current_column++;
      $output[$current_column] = $column;
    }
    $i++;
  }
  return $output;
}