protected function CshsFormatterBase::getTermParents in Client-side Hierarchical Select 8.3
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldFormatter/CshsFormatterBase.php \Drupal\cshs\Plugin\Field\FieldFormatter\CshsFormatterBase::getTermParents()
- 8.2 src/Plugin/Field/FieldFormatter/CshsFormatterBase.php \Drupal\cshs\Plugin\Field\FieldFormatter\CshsFormatterBase::getTermParents()
Returns an array of all parents for a given term.
Parameters
\Drupal\taxonomy\TermInterface $term: The taxonomy term.
bool $start_from_root: The state of whether to return the hierarchy starting from the root or vice versa.
Return value
\Drupal\taxonomy\TermInterface[] The parent terms of a given term.
2 calls to CshsFormatterBase::getTermParents()
- CshsFullHierarchyFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ CshsFullHierarchyFormatter.php - Builds a renderable array for a field value.
- CshsGroupByRootFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ CshsGroupByRootFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ CshsFormatterBase.php, line 103
Class
- CshsFormatterBase
- Base formatter for CSHS field.
Namespace
Drupal\cshs\Plugin\Field\FieldFormatterCode
protected function getTermParents(TermInterface $term, bool $start_from_root = TRUE) : array {
$hierarchy = $this
->getTermStorage()
->loadAllParents($term
->id());
// By default, the `$hierarchy` ends by the root term.
return $start_from_root ? \array_reverse($hierarchy) : $hierarchy;
}