devilcius / admin-menu-bundle
Extended menu to use with Symfony2 and sonata-admin
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- sonata-project/admin-bundle: >=2.2-dev,<2.3-dev
This package is not auto-updated.
Last update: 2024-11-18 14:28:41 UTC
README
This is based on AdminBundle and extends the SonataAdminBundle. It offers the possibility to manage the menu from other bundle.
See how to install and configure
Manage menu
The SonataAdminBundle main menu (on top of all Admin pages) is generated with a list of Admin objects.
This bundle extends the menu and allows everyone to modify via the service container.
The admin menu is generated with KnpMenu library. By default it retrieves all admin groups and labels Admin (like the default menu renderer).
To modify the admin menu just register a listener :
namespace devilcius\TestBundle\EventListener; class MenuListener { public function createMenu($event) { $menu = $event->getMenu(); // create a new group $menu->addChild('Audit', array('translationDomain'=>'MyDomain')); // add a divider to System group $menu['Audit']->addDivider(); // ad a nav header $menu['Audit']->addNavHeader('SubMenu'); // add list child (with a route declared in routing.yml) $menu['Audit']->addChild('List', array('uri' => $this->router->generate('get_audit_list'))); } }
And just declare the listener in your services.yml file.
services: kernel.listener.admin_menu_listener: class: devilcius\TestBundle\EventListener\MenuListener tags: - { name: kernel.event_listener, event: admin.menu.create, method: createMenu } arguments: [@router]
This bundle use a custom MenuItem class devilcius\AdminMenuBundle\Menu\MenuItem
that extends the Knp\Menu\MenuItem
. It add new functions (dividers, nav headers, ...)
Controllers used in the the admin menu must extend the AdminMenuController
use devilcius\AdminMenuBundle\Controller\AdminMenuController as Controller; class AuditController extends Controller { [...]