You are here

public function AdvancedHelpController::main in Advanced Help 8

Content.

@todo Implement search integration.

Return value

array Returns module index.

1 string reference to 'AdvancedHelpController::main'
advanced_help.routing.yml in ./advanced_help.routing.yml
advanced_help.routing.yml

File

src/Controller/AdvancedHelpController.php, line 54

Class

AdvancedHelpController
Class AdvancedHelpController.

Namespace

Drupal\advanced_help\Controller

Code

public function main() {
  $topics = $this->advanced_help
    ->getTopics();
  $settings = $this->advanced_help
    ->getSettings();

  // Print a module index.
  $modules = $this->advanced_help
    ->getModuleList();
  asort($modules);
  $items = [];
  foreach ($modules as $module => $module_name) {
    if (!empty($topics[$module]) && empty($settings[$module]['hide'])) {
      if (isset($settings[$module]['index name'])) {
        $name = $settings[$module]['index name'];
      }
      elseif (isset($settings[$module]['name'])) {
        $name = $settings[$module]['name'];
      }
      else {
        $name = $this
          ->t($module_name);
      }
      $items[] = Link::fromTextAndUrl($name, Url::fromRoute('advanced_help.module_index', [
        'module' => $module,
      ]));
    }
  }
  return [
    'help_modules' => [
      '#theme' => 'item_list',
      '#items' => $items,
      '#title' => $this
        ->t('Module help index'),
    ],
  ];
}