You are here

protected function Taxonomy::taxonomyGetParent in Facets 8

Returns the parent tid for a given tid, or false if no parent exists.

Parameters

int $tid: A taxonomy term id.

Return value

int|false Returns FALSE if no parent is found, else parent tid.

1 call to Taxonomy::taxonomyGetParent()
Taxonomy::getParentIds in src/Plugin/facets/hierarchy/Taxonomy.php
Retrieve all parent ids for one specific id.

File

src/Plugin/facets/hierarchy/Taxonomy.php, line 168

Class

Taxonomy
Taxonomy hierarchy.

Namespace

Drupal\facets\Plugin\facets\hierarchy

Code

protected function taxonomyGetParent($tid) {
  if (isset($this->termParents[$tid])) {
    return $this->termParents[$tid];
  }
  $parents = $this->termStorage
    ->loadParents($tid);
  if (empty($parents)) {
    return FALSE;
  }
  return $this->termParents[$tid] = reset($parents)
    ->id();
}