You are here

public function AdvancedHelpController::topicPage in Advanced Help 8

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

File

src/Controller/AdvancedHelpController.php, line 228

Class

AdvancedHelpController
Class AdvancedHelpController.

Namespace

Drupal\advanced_help\Controller

Code

public function topicPage(Request $request, $module, $topic) {
  $is_modal = $request->query
    ->get(MainContentViewSubscriber::WRAPPER_FORMAT) === 'drupal_modal';
  $info = $this->advanced_help
    ->getTopic($module, $topic);
  if (!$info) {
    throw new NotFoundHttpException();
  }
  $parent = $info;
  $pmodule = $module;

  // Loop checker.
  $checked = [];
  while (!empty($parent['parent'])) {
    if (strpos($parent['parent'], '%')) {
      list($pmodule, $ptopic) = explode('%', $parent['parent']);
    }
    else {
      $ptopic = $parent['parent'];
    }
    if (!empty($checked[$pmodule][$ptopic])) {
      break;
    }
    $checked[$pmodule][$ptopic] = TRUE;
    $parent = $this->advanced_help
      ->getTopic($pmodule, $ptopic);
    if (!$parent) {
      break;
    }
  }
  $build = $this
    ->viewTopic($module, $topic, $is_modal);
  if (empty($build['#markup'])) {
    $build['#markup'] = $this
      ->t('Missing help topic.');
  }
  $build['#attached']['library'][] = 'advanced_help/help';
  return $build;
}