function TermStorage::loadParents
Same name in other branches
- 9 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::loadParents()
- 10 core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::loadParents()
- 11.x core/modules/taxonomy/src/TermStorage.php \Drupal\taxonomy\TermStorage::loadParents()
Overrides TermStorageInterface::loadParents
File
-
core/
modules/ taxonomy/ src/ TermStorage.php, line 106
Class
- TermStorage
- Defines a Controller class for taxonomy terms.
Namespace
Drupal\taxonomyCode
public function loadParents($tid) {
$terms = [];
/** @var \Drupal\taxonomy\TermInterface $term */
if ($tid && ($term = $this->load($tid))) {
foreach ($this->getParents($term) as $id => $parent) {
// This method currently doesn't return the <root> parent.
// @see https://www.drupal.org/node/2019905
if (!empty($id)) {
$terms[$id] = $parent;
}
}
}
return $terms;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.