function TermTest::getParentTids
Same name in other branches
- 10 core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::getParentTids()
- 11.x core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::getParentTids()
Get the parent tids for a term including root.
Parameters
\Drupal\taxonomy\TermInterface $term: The term.
Return value
array A sorted array of tids and 0 if the root is a parent.
1 call to TermTest::getParentTids()
- TermTest::testTermMultipleParentsInterface in core/
modules/ taxonomy/ tests/ src/ Functional/ TermTest.php - Tests saving a term with multiple parents through the UI.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TermTest.php, line 631
Class
- TermTest
- Tests load, save and delete for taxonomy terms.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
private function getParentTids($term) {
$parent_tids = [];
foreach ($term->get('parent') as $item) {
$parent_tids[] = (int) $item->target_id;
}
sort($parent_tids);
return $parent_tids;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.