You are here

public function Taxonomy::getChildIds in Facets 8

Retrieve the direct children for an array of ids.

Parameters

array $ids: An array of ids.

Return value

array Given parent ids as key, value is an array of child ids.

Overrides HierarchyInterface::getChildIds

1 call to Taxonomy::getChildIds()
Taxonomy::getSiblingIds in src/Plugin/facets/hierarchy/Taxonomy.php
Provide a default implementation for backward compatibility.

File

src/Plugin/facets/hierarchy/Taxonomy.php, line 105

Class

Taxonomy
Taxonomy hierarchy.

Namespace

Drupal\facets\Plugin\facets\hierarchy

Code

public function getChildIds(array $ids) {
  $parents = [];
  foreach ($ids as $id) {
    $terms = $this->termStorage
      ->loadChildren($id);
    $parents[$id] = array_filter(array_values(array_map(function ($it) {
      return $it
        ->id();
    }, $terms)));
  }
  $parents = array_filter($parents);
  return $parents;
}