do not display admin menu if it has no children (#500)

This commit is contained in:
Kevin Papst
2019-01-17 01:25:00 +01:00
committed by GitHub
parent 825d31af20
commit 5d5b971f57
9 changed files with 87 additions and 96 deletions

View File

@@ -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(