Nowo\DashboardMenuBundle\Service\MenuCodeResolverInterface
Implement this interface to resolve the effective menu code from the current request and a hint string. This lets you serve different menu variants to different tenants, operators, or partners without changing template code.
The resolver is called by:
dashboard_menu_tree()anddashboard_menu_config()in TwigGET /api/menu/{code}in the JSON API
Interface
Method
Returns the resolved menu code that the bundle will use to query the database.
Parameters
The current Symfony
HttpFoundation\Request. Use this to read route attributes, session data, headers, or any other request information needed to determine the correct menu code.The menu code hint as passed from the template or API path (e.g.
sidebar). The resolver should fall back to returning this value unchanged when no more-specific menu is found.Default implementation
DefaultMenuCodeResolver is used when no custom resolver is configured. It returns the hint unchanged:
Custom implementation
The following example resolves menus usingoperatorId and partnerId route attributes, falling back to progressively simpler codes until the hint itself:
Registration
The bundle registersDefaultMenuCodeResolver as the implementation of MenuCodeResolverInterface by default. Override it by aliasing the interface in your services.yaml:
config/services.yaml
App\ resource autodiscovery covers this automatically when your class is in src/:
config/services.yaml
There is no
menu_code_resolver key in nowo_dashboard_menu.yaml. Registration is done entirely through the Symfony service container by replacing the MenuCodeResolverInterface alias.The same resolver instance is used for both the Twig functions and the JSON API endpoint. A change in the resolver affects all rendering paths simultaneously.