public function Taxonomy::getNestedChildIds in Facets 8
Retrieve all children and nested children for one specific id.
Parameters
string $id: An entity id.
Return value
array An array of all child ids.
Overrides HierarchyInterface::getNestedChildIds
File
- src/
Plugin/ facets/ hierarchy/ Taxonomy.php, line 85
Class
- Taxonomy
- Taxonomy hierarchy.
Namespace
Drupal\facets\Plugin\facets\hierarchyCode
public function getNestedChildIds($id) {
if (isset($this->nestedChildren[$id])) {
return $this->nestedChildren[$id];
}
$children = $this->termStorage
->loadChildren($id);
$children = array_filter(array_values(array_map(function ($it) {
return $it
->id();
}, $children)));
$subchilds = [];
foreach ($children as $child) {
$subchilds = array_merge($subchilds, $this
->getNestedChildIds($child));
}
return $this->nestedChildren[$id] = array_merge($children, $subchilds);
}