do not display admin menu if it has no children (#500)
This commit is contained in:
@@ -61,8 +61,6 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
|
||||
public function onSetupNavbar(SidebarMenuEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$isLoggedIn = $this->security->isGranted('IS_AUTHENTICATED_REMEMBERED');
|
||||
$isTeamlead = $isLoggedIn && $this->security->isGranted('ROLE_TEAMLEAD');
|
||||
|
||||
$event->addItem(
|
||||
new MenuItemModel('dashboard', 'menu.homepage', 'dashboard', [], 'fas fa-tachometer-alt')
|
||||
@@ -76,17 +74,18 @@ class MenuBuilderSubscriber implements EventSubscriberInterface
|
||||
)
|
||||
);
|
||||
|
||||
if ($isTeamlead) {
|
||||
$admin = new MenuItemModel('admin', 'menu.admin', '', [], 'fas fa-wrench');
|
||||
$event->addItem($admin);
|
||||
$admin = new MenuItemModel('admin', 'menu.admin', '', [], 'fas fa-wrench');
|
||||
|
||||
$this->eventDispatcher->dispatch(
|
||||
ConfigureAdminMenuEvent::CONFIGURE,
|
||||
new ConfigureAdminMenuEvent(
|
||||
$request,
|
||||
$event
|
||||
)
|
||||
);
|
||||
$this->eventDispatcher->dispatch(
|
||||
ConfigureAdminMenuEvent::CONFIGURE,
|
||||
new ConfigureAdminMenuEvent(
|
||||
$request,
|
||||
$admin
|
||||
)
|
||||
);
|
||||
|
||||
if ($admin->hasChildren()) {
|
||||
$event->addItem($admin);
|
||||
}
|
||||
|
||||
$this->activateByRoute(
|
||||
|
||||
Reference in New Issue
Block a user