-
Notifications
You must be signed in to change notification settings - Fork 146
Open
Milestone
Description
I have installed the latest master bundle and everything works ok, but the KNP Setup gives me:
The menu "avanzu_main" is not defined.
routing.yml
avanzu_admin_home:
path: /
defaults: {_controller: AppBundle:Default:index}
options:
avanzu_admin_route: welcome
services.yml
app.setup_knp_menu_listener:
class: AppBundle\EventListener\SetupKnpMenuListener
tags:
- { name: kernel.event_listener, event: theme.sidebar_setup_knp_menu, method: onSetupMenu }
Admin Theme Configuration
avanzu_admin_theme:
options:
knp_menu:
enable : true
AppBundle/EventListener/SetupKnpMenuListener.php
<?php
/**
* Created by PhpStorm.
* User: edgarkussberg
* Date: 30.11.17
* Time: 09:38
*/
namespace AppBundle\EventListener;
use Avanzu\AdminThemeBundle\Event\KnpMenuEvent;
class SetupKnpMenuListener
{
public function onSetupMenu(KnpMenuEvent $event)
{
$menu = $event->getMenu();
// Adds a menu item which acts as a label
$menu->addChild('MainNavigationMenuItem', [
'label' => 'MAIN NAVIGATION',
'childOptions' => $event->getChildOptions()
]
)->setAttribute('class', 'header');
// A "regular" menu item with a link
$menu->addChild('TestMenuItem', [
'route' => 'homepage',
'label' => 'Homepage',
'childOptions' => $event->getChildOptions()
]
)->setLabelAttribute('icon', 'fa fa-flag');
// Adds a menu item which has children
$menu->addChild('DataMenuItem', [
'label' => 'Database mangement',
'childOptions' => $event->getChildOptions()
]
)->setLabelAttribute('icon', 'fa fa-database');
// First child, a regular menu item
$menu->getChild('DataMenuItem')->addChild('DataUsersMenuItem', [
'route' => 'app.database.users',
'label' => 'Users table',
'childOptions' => $event->getChildOptions()
]
)->setLabelAttribute('icon', 'fa fa-user');
// Second child, a regular menu item
$menu->getChild('DataMenuItem')->addChild('DataGroupsMenuItem', [
'route' => 'app.database.groups',
'label' => 'Groups table',
'childOptions' => $event->getChildOptions()
]
)->setLabelAttribute('icon', 'fa fa-users');
}
}
Reactions are currently unavailable