MenuPermissionCheckerInterface. A menu can have one checker assigned; the checker decides — item by item — whether that item appears in the rendered tree.
The interface
canView receives the MenuItem entity and an optional $context value. The context is whatever you pass as the $permissionContext argument when loading the tree (e.g. the current User object or the Symfony Request).
Built-in checkers
The bundle ships two checkers.Writing a custom checker
Create the class
Implement
MenuPermissionCheckerInterface in any service class. The Symfony service container will auto-register it:Set a dashboard label (optional)
Give your checker a human-readable name in the dashboard dropdown using either approach:If neither is set, the dashboard shows the service ID (the FQCN) as the label.
Auto-registration
Any service whose class implementsMenuPermissionCheckerInterface is automatically discovered and added to the dashboard’s “Permission checker” dropdown. You do not need to add a tag in services.yaml.
Your checker will be discovered automatically as long as your service is auto-registered (e.g. via
App\Service\: resource: '../src/Service/' in services.yaml). Explicit tagging with nowo_dashboard_menu.permission_checker or #[AsTaggedItem] is still supported but not required.Pruning empty parents
After the permission checker filters individual items, the bundle performs a prune pass. Any parent item or section header that originally had children but now has none visible is removed from the tree. This prevents orphaned group labels from appearing in the rendered menu.Passing permission context
The$context parameter of canView comes from the $permissionContext argument you pass when loading the tree:
canView call. Its type and semantics are entirely up to your checker implementation.