MenuExtension.
dashboard_menu_tree
Loads and returns the menu tree for a given menu code.list<array{item: MenuItem, children: list<array>}>
Each entry in the returned list is an associative array with two keys:
item— theMenuItementitychildren— a recursively structured list of the same shape
MenuPermissionCheckerInterface are included. Parents whose children are all hidden are automatically pruned from the tree.
Parameters
The menu code hint (e.g.
sidebar). Passed through MenuCodeResolverInterface, so the resolved code may differ from the hint.Context value passed to
MenuPermissionCheckerInterface::canView(). When null (or omitted), the current Request object is used as the context automatically.Ordered list of context objects for resolving which menu variant to use. Each element is either an associative array of key-value pairs (e.g.
{'partnerId': 1}) or null to match the context-free menu. The first matching menu is used. When null or omitted, default resolution (no context filtering) is applied.Usage
dashboard_menu_config
Returns the render configuration for a menu. Use this when you need CSS classes, depth limit, icon settings, or collapsible behaviour in a custom template.array with the following keys:
Parameters
The menu code hint. Resolved through
MenuCodeResolverInterface the same way as in dashboard_menu_tree.Ordered list of context objects for variant resolution. Same semantics as in
dashboard_menu_tree.Return value
CSS class strings keyed by element name (e.g.
menu, item, link, children). Values come from the Menu entity configuration.HTML
id attribute to apply to the root <ul> element. null when not set.When
true, the template wraps item content in an additional <span> element for active-state styling. Controlled by global bundle configuration.CSS class applied to the item content
<span> when item_span_active is true. Defaults to d-flex align-items-center flex-nowrap.Icon size value (CSS length, e.g.
1em). Passed to the icon rendering helper. Defaults to 1em.Maximum depth to render. The template stops recursing below this level.
null means unlimited.Icon rendering settings.
When
true, the entire menu is wrapped in a collapsible block with a toggle button. Configured on the Menu entity.Initial expanded state when
collapsible is true.When
true, individual items with children render a chevron to expand/collapse their nested list.Human-readable name of the resolved menu.
null when not set.Usage
dashboard_menu_href
Generates a URL string from aMenuItem object.
string
Parameters
A
MenuItem entity, as received from the item key inside a dashboard_menu_tree node.Symfony
UrlGeneratorInterface reference type constant:0—ABSOLUTE_PATH(default): returns/path/to/page1—ABSOLUTE_URL: returnshttps://example.com/path/to/page2—RELATIVE_PATH: returns a relative URL3—NETWORK_PATH: returns//example.com/path/to/page