ToolbarMenuLinkTree
class ToolbarMenuLinkTree extends MenuLinkTree (View source)
Extends MenuLinkTree to add specific theme suggestions for the toolbar.
Properties
| protected MenuTreeStorageInterface | $treeStorage | The menu link tree storage. |
from MenuLinkTree |
| protected MenuLinkManagerInterface | $menuLinkManager | The menu link plugin manager. |
from MenuLinkTree |
| protected RouteProviderInterface | $routeProvider | The route provider to load routes by name. |
from MenuLinkTree |
| protected MenuActiveTrailInterface | $menuActiveTrail | The active menu trail service. |
from MenuLinkTree |
| protected ControllerResolverInterface | $controllerResolver | The controller resolver. |
from MenuLinkTree |
Methods
Constructs a \Drupal\Core\Menu\MenuLinkTree object.
Gets the link tree parameters for rendering a specific menu.
Loads a menu tree with a menu link plugin instance at each element.
Returns a tree containing of MenuLinkTreeElement based upon tree data.
Applies menu link tree manipulators to transform the given tree.
Builds a renderable array from a menu tree.
Builds the #items property for a menu tree's renderable array.
Finds the height of a subtree rooted by of the given ID.
Finds expanded links in a menu given a set of possible parents.
Details
__construct(MenuTreeStorageInterface $tree_storage, MenuLinkManagerInterface $menu_link_manager, RouteProviderInterface $route_provider, MenuActiveTrailInterface $menu_active_trail, ControllerResolverInterface $controller_resolver)
Constructs a \Drupal\Core\Menu\MenuLinkTree object.
MenuTreeParameters
getCurrentRouteMenuTreeParameters(string $menu_name)
Gets the link tree parameters for rendering a specific menu.
Builds menu link tree parameters that:
- Expand all links in the active trail based on route being viewed.
- Expand the descendants of the links in the active trail whose 'expanded' flag is enabled.
This only sets the (relatively complex) parameters to achieve the two above goals, but you can still further customize these parameters.
MenuLinkTreeElement[]
load(string $menu_name, MenuTreeParameters $parameters)
Loads a menu tree with a menu link plugin instance at each element.
protected MenuLinkTreeElement[]
createInstances(array $data_tree)
Returns a tree containing of MenuLinkTreeElement based upon tree data.
This method converts the tree representation as array coming from the tree storage to a tree containing a list of MenuLinkTreeElement[].
MenuLinkTreeElement[]
transform(array $tree, array $manipulators)
Applies menu link tree manipulators to transform the given tree.
array
build(array $tree, $level = 0)
Builds a renderable array from a menu tree.
The menu item's LI element is given one of the following classes:
- expanded: The menu item is showing its submenu.
- collapsed: The menu item has a submenu that is not shown.
- leaf: The menu item has no submenu.
protected array
buildItems(array $tree, CacheableMetadata $tree_access_cacheability, CacheableMetadata $tree_link_cacheability)
Builds the #items property for a menu tree's renderable array.
Helper function for ::build().
int
maxDepth()
Returns the maximum depth of tree that is supported.
int
getSubtreeHeight(string $id)
Finds the height of a subtree rooted by of the given ID.
array
getExpanded(string $menu_name, array $parents)
Finds expanded links in a menu given a set of possible parents.