private function MenuTree::buildMenuTreeRecursively in Taxonomy Facets 8
1 call to MenuTree::buildMenuTreeRecursively()
- MenuTree::__construct in src/MenuTree.php
File
- src/MenuTree.php, line 33
Class
- MenuTree
Namespace
Drupal\taxonomy_facets
Code
private function buildMenuTreeRecursively($parent) {
$tree = \Drupal::entityTypeManager()
->getStorage('taxonomy_term')
->loadTree($this->vid, $parent, 1);
$begin_ul = [
'#theme' => 'taxonomy_facets_ul_wrapper_begin_template',
'#menuClass' => $this->menu_class,
'#attached' => [
'library' => [
'taxonomy_facets/change_links',
],
],
];
$this->menu_class = NULL;
$this->menuTree[] = render($begin_ul);
foreach ($tree as $leaf) {
if (true) {
$menuItemInChildrenLeafs = $this
->menuItemInChildrenLeafs($leaf->tid);
$leafCssClass = $this
->calculateItemCssClass($menuItemInChildrenLeafs, $leaf->tid);
$leaf = new MenuLeaf($leaf, $leafCssClass);
$this->menuTree[] = [
'#theme' => 'taxonomy_facets_menu_leaf_template',
'#menuLeaf' => $leaf,
];
if ($menuItemInChildrenLeafs || $this
->menuItemIsFilterApplied($leaf->tid)) {
$this
->buildMenuTreeRecursively($leaf->tid);
}
}
}
$end_ul = [
'#theme' => 'taxonomy_facets_ul_wrapper_end_template',
];
$this->menuTree[] = render($end_ul);
}