function TermForm::getParentIds
Same name in other branches
- 9 core/modules/taxonomy/src/TermForm.php \Drupal\taxonomy\TermForm::getParentIds()
- 10 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
File
-
core/
modules/ taxonomy/ src/ TermForm.php, line 239
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.