public function MenuSelectTreeBuilder::loadMenuTree in Menu Select 8
Same name and namespace in other branches
- 2.0.x src/MenuSelectTreeBuilder.php \Drupal\menu_select\MenuSelectTreeBuilder::loadMenuTree()
Function to build a menu tree from a menu name.
Parameters
string $menu_name: Menu name to use.
int $max_depth: The maximum depth to traverse.
Return value
\Drupal\Core\Menu\MenuLinkTreeElement[] Array of the menu tree.
Overrides MenuSelectTreeBuilderInterface::loadMenuTree
File
- src/
MenuSelectTreeBuilder.php, line 44
Class
- MenuSelectTreeBuilder
- A service for building out the menu trees used in menu select.
Namespace
Drupal\menu_selectCode
public function loadMenuTree($menu_name, $max_depth) {
$parameters = new MenuTreeParameters();
$parameters
->setMaxDepth($max_depth);
$tree = $this->menuTree
->load($menu_name, $parameters);
return $this->menuTree
->transform($tree, $this->manipulators);
}