public function ForumController::forumIndex in Drupal 10
Same name and namespace in other branches
- 8 core/modules/forum/src/Controller/ForumController.php \Drupal\forum\Controller\ForumController::forumIndex()
- 9 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 177
Class
- ForumController
- Controller routines for forum routes.
Namespace
Drupal\forum\ControllerCode
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;
}