Nowo\DashboardMenuBundle\Service\MenuPermissionCheckerInterface
Implement this interface to control which menu items are visible in a given context. The bundle calls canView() for every item when loading the tree. Items that return false are hidden, and any parent (including section titles) whose children all become hidden is automatically pruned.
Interface
Method
Return
true to show the item, false to hide it.Parameters
The menu item being evaluated. Use
$item->getPermissionKey() to read the optional permission key configured per item in the dashboard, or inspect any other property.Contextual value passed by the caller. When invoked from a Twig template via
dashboard_menu_tree(), this is the $permissionContext argument (defaults to the current Request object when not supplied). When invoked from the JSON API, this is always null.Auto-registration
Any service whose class implementsMenuPermissionCheckerInterface is automatically discovered and included in the dashboard Permission checker dropdown. You do not need to add any tag in services.yaml.
For this to work, the service must be visible to Symfony’s dependency injection container. The standard App\Service\ resource autodiscovery in services.yaml covers this automatically:
services.yaml
Setting the dashboard label
Optionally set a human-readable label for the dashboard dropdown using either approach:Class constant
Attribute
Example: Symfony security checker
Reference implementation: AllowAllMenuPermissionChecker
The bundle shipsAllowAllMenuPermissionChecker as the default when no custom checker is configured. It always returns true, meaning every item is visible.
Parents and section headings with no visible children are automatically pruned from the tree — you only need to return
false for the leaf items that should be hidden.Assigning a checker to a menu
Assign your checker to a specific menu in the dashboard UI (per-menu configuration, gear icon). Menus with no checker assigned use the allow-all default. You can also control the order and labels shown in the dashboard dropdown viapermission_checker_choices in nowo_dashboard_menu.yaml:
nowo_dashboard_menu.yaml