You are here

public function TermStorage::loadAllParents in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::loadAllParents()

Finds all ancestors of a given term ID.

Parameters

int $tid: Term ID to retrieve ancestors for.

Return value

\Drupal\taxonomy\TermInterface[] An array of term objects which are the ancestors of the term $tid.

Overrides TermStorageInterface::loadAllParents

File

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

Class

TermStorage
Defines a Controller class for taxonomy terms.

Namespace

Drupal\taxonomy

Code

public function loadAllParents($tid) {

  /** @var \Drupal\taxonomy\TermInterface $term */
  return !empty($tid) && ($term = $this
    ->load($tid)) ? $this
    ->getAncestors($term) : [];
}