function ForumManager::getChildren
Same name in other branches
- 9 core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getChildren()
- 8.9.x core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getChildren()
- 11.x core/modules/forum/src/ForumManager.php \Drupal\forum\ForumManager::getChildren()
1 call to ForumManager::getChildren()
- ForumManager::getIndex in core/
modules/ forum/ src/ ForumManager.php
File
-
core/
modules/ forum/ src/ ForumManager.php, line 411
Class
- ForumManager
- Provides forum manager service.
Namespace
Drupal\forumCode
public function getChildren($vid, $tid) {
if (!empty($this->forumChildren[$tid])) {
return $this->forumChildren[$tid];
}
$forums = [];
$_forums = $this->entityTypeManager
->getStorage('taxonomy_term')
->loadTree($vid, $tid, NULL, TRUE);
foreach ($_forums as $forum) {
if (!$forum->access('view')) {
continue;
}
// Merge in the topic and post counters.
if ($count = $this->getForumStatistics($forum->id())) {
$forum->num_topics = $count->topic_count;
$forum->num_posts = $count->topic_count + $count->comment_count;
}
else {
$forum->num_topics = 0;
$forum->num_posts = 0;
}
// Merge in last post details.
$forum->last_post = $this->getLastPost($forum->id());
$forums[$forum->id()] = $forum;
}
$this->forumChildren[$tid] = $forums;
return $forums;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.