public static function FaqHelper::taxonomyTermChildren in Frequently Asked Questions 8
Helper function to taxonomyTermCountNodes() to return list of child terms.
1 call to FaqHelper::taxonomyTermChildren()
- FaqHelper::taxonomyTermCountNodes in src/
FaqHelper.php - Count number of nodes for a term and its children.
File
- src/
FaqHelper.php, line 78
Class
- FaqHelper
- Contains static helper functions for FAQ module.
Namespace
Drupal\faqCode
public static function taxonomyTermChildren($tid) {
static $children;
if (!isset($children)) {
$result = \Drupal::database()
->select('taxonomy_term__parent', 'tth')
->fields('tth', array(
'entity_id',
'parent_target_id',
))
->execute();
while ($term = $result
->fetch()) {
$children[$term->parent_target_id][] = $term->entity_id;
}
}
return isset($children[$tid]) ? $children[$tid] : array();
}