You are here

public function ForumManager::getIndex in Zircon Profile 8

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

Generates and returns the forum index.

The forum index is a pseudo term that provides an overview of all forums.

Return value

\Drupal\taxonomy\TermInterface A pseudo term representing the overview of all forums.

Overrides ForumManagerInterface::getIndex

File

core/modules/forum/src/ForumManager.php, line 432
Contains \Drupal\forum\ForumManager.

Class

ForumManager
Provides forum manager service.

Namespace

Drupal\forum

Code

public function getIndex() {
  if ($this->index) {
    return $this->index;
  }
  $vid = $this->configFactory
    ->get('forum.settings')
    ->get('vocabulary');
  $index = $this->entityManager
    ->getStorage('taxonomy_term')
    ->create(array(
    'tid' => 0,
    'container' => 1,
    'parents' => array(),
    'isIndex' => TRUE,
    'vid' => $vid,
  ));

  // Load the tree below.
  $index->forums = $this
    ->getChildren($vid, 0);
  $this->index = $index;
  return $index;
}