function TermForm::getParentIds
Same name in other branches
- 10 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::getParentIds()
- 11.x core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::getParentIds()
Returns term parent IDs, including the root.
Parameters
\Drupal\taxonomy\TermInterface $term: The taxonomy term entity.
Return value
array A list if parent term IDs.
1 call to TermForm::getParentIds()
- TermForm::form in core/
modules/ taxonomy/ src/ TermForm.php - Gets the actual form array to be built.
File
-
core/
modules/ taxonomy/ src/ TermForm.php, line 227
Class
- TermForm
- Base for handler for taxonomy term edit forms.
Namespace
Drupal\taxonomyCode
protected function getParentIds(TermInterface $term) : array {
$parent = [];
// Get the parent directly from the term as
// \Drupal\taxonomy\TermStorageInterface::loadParents() excludes the root.
foreach ($term->get('parent') as $item) {
$parent[] = (int) $item->target_id;
}
return $parent;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.