You are here

public function Drupal8::taxonomyLoadTree in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::taxonomyLoadTree()
  2. 7.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::taxonomyLoadTree()

Load a taxonomy tree.

Parameters

object $vocabulary: A Drupal vocabulary object.

Return value

array An array of taxonomy term objects.

Throws

\Exception

Overrides Framework::taxonomyLoadTree

File

api/src/Framework/Drupal8.php, line 428

Class

Drupal8
Drupal 8-specific code.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function taxonomyLoadTree($vocabulary) {

  // @phpstan-ignore-next-line
  $terms = \Drupal::entityTypeManager()
    ->getStorage('taxonomy_term')
    ->loadTree($this
    ->vocabularyIdentifier($vocabulary));
  $tids = array_map(function ($a) {
    return $a->tid;
  }, $terms);
  return Term::loadMultiple($tids);
}