function TermStorage::getChildren

Same name in other branches
  1. 8.9.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getChildren()
  2. 10 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getChildren()
  3. 11.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::getChildren()

Returns all children terms of this term.

@internal @todo Refactor away when TreeInterface is introduced.

Return value

\Drupal\taxonomy\TermInterface[] A list of children taxonomy term entities keyed by term ID.

1 call to TermStorage::getChildren()
TermStorage::loadChildren in core/modules/taxonomy/src/TermStorage.php
Finds all children of a term ID.

File

core/modules/taxonomy/src/TermStorage.php, line 210

Class

TermStorage
Defines a Controller class for taxonomy terms.

Namespace

Drupal\taxonomy

Code

public function getChildren(TermInterface $term) {
    $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(TRUE)
        ->condition('parent', $term->id());
    return static::loadMultiple($query->execute());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.