You are here

protected function ForumController::build 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::build()

Returns a renderable forum index page array.

Parameters

array $forums: A list of forums.

\Drupal\taxonomy\TermInterface $term: The taxonomy term of the forum.

array $topics: The topics of this forum.

array $parents: The parent forums in relation this forum.

array $header: Array of header cells.

Return value

array A render array.

2 calls to ForumController::build()
ForumController::forumIndex in core/modules/forum/src/Controller/ForumController.php
Returns forum index page.
ForumController::forumPage in core/modules/forum/src/Controller/ForumController.php
Returns forum page for a given forum.

File

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

Class

ForumController
Controller routines for forum routes.

Namespace

Drupal\forum\Controller

Code

protected function build($forums, TermInterface $term, $topics = array(), $parents = array(), $header = array()) {
  $config = $this
    ->config('forum.settings');
  $build = array(
    '#theme' => 'forums',
    '#forums' => $forums,
    '#topics' => $topics,
    '#parents' => $parents,
    '#header' => $header,
    '#term' => $term,
    '#sortby' => $config
      ->get('topics.order'),
    '#forums_per_page' => $config
      ->get('topics.page_limit'),
  );
  if (empty($term->forum_container->value)) {
    $build['#attached']['feed'][] = array(
      'taxonomy/term/' . $term
        ->id() . '/feed',
      'RSS - ' . $term
        ->getName(),
    );
  }
  $this->renderer
    ->addCacheableDependency($build, $config);
  foreach ($forums as $forum) {
    $this->renderer
      ->addCacheableDependency($build, $forum);
  }
  foreach ($topics as $topic) {
    $this->renderer
      ->addCacheableDependency($build, $topic);
  }
  foreach ($parents as $parent) {
    $this->renderer
      ->addCacheableDependency($build, $parent);
  }
  $this->renderer
    ->addCacheableDependency($build, $term);
  return [
    'action' => $this
      ->buildActionLinks($config
      ->get('vocabulary'), $term),
    'forum' => $build,
    '#cache' => [
      'tags' => Cache::mergeTags($this->nodeEntityTypeDefinition
        ->getListCacheTags(), $this->commentEntityTypeDefinition
        ->getListCacheTags()),
    ],
  ];
}