You are here

public function ForumController::forumIndex in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/forum/src/Controller/ForumController.php \Drupal\forum\Controller\ForumController::forumIndex()

Returns forum index page.

Return value

array A render array.

1 string reference to 'ForumController::forumIndex'
forum.routing.yml in core/modules/forum/forum.routing.yml
core/modules/forum/forum.routing.yml

File

core/modules/forum/src/Controller/ForumController.php, line 182
Contains \Drupal\forum\Controller\ForumController.

Class

ForumController
Controller routines for forum routes.

Namespace

Drupal\forum\Controller

Code

public function forumIndex() {
  $vocabulary = $this->vocabularyStorage
    ->load($this
    ->config('forum.settings')
    ->get('vocabulary'));
  $index = $this->forumManager
    ->getIndex();
  $build = $this
    ->build($index->forums, $index);
  if (empty($index->forums)) {

    // Root of empty forum.
    $build['#title'] = $this
      ->t('No forums defined');
  }
  else {

    // Set the page title to forum's vocabulary name.
    $build['#title'] = $vocabulary
      ->label();
    $this->renderer
      ->addCacheableDependency($build, $vocabulary);
  }
  return $build;
}