private function HierarchicalTaxonomyMenuBlock::generateTree in Hierarchical Taxonomy Menu 8
Generates menu tree.
1 call to HierarchicalTaxonomyMenuBlock::generateTree()
- HierarchicalTaxonomyMenuBlock::build in src/
Plugin/ Block/ HierarchicalTaxonomyMenuBlock.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ HierarchicalTaxonomyMenuBlock.php, line 642
Class
- HierarchicalTaxonomyMenuBlock
- Provides a 'HierarchicalTaxonomyMenuBlock' block.
Namespace
Drupal\hierarchical_taxonomy_menu\Plugin\BlockCode
private function generateTree($array, $parent = 0) {
$tree = [];
foreach ($array as $item) {
if (reset($item['parents']) == $parent && $item['status'] == 1) {
$item['subitem'] = isset($item['subitem']) ? $item['subitem'] : $this
->generateTree($array, $item['tid']);
$tree[] = $item;
}
}
return $tree;
}