dev-master
9999999-dev https://github.com/devilcius/AdminMenuBundleExtended menu to use with Symfony2 and sonata-admin
MIT
The Requires
- php >=5.3.2
- sonata-project/admin-bundle >=2.2-dev,<2.3-dev
by Marcos
bundle symfony sonata-admin
Extended menu to use with Symfony2 and sonata-admin
This is based on AdminBundle and extends the SonataAdminBundle. It offers the possibility to manage the menu from other bundle., (*2)
See how to install and configure, (*3)
The SonataAdminBundle main menu (on top of all Admin pages) is generated with a list of Admin objects., (*4)
This bundle extends the menu and allows everyone to modify via the service container., (*5)
The admin menu is generated with [KnpMenu][4] library. By default it retrieves all admin groups and labels Admin (like the default menu renderer)., (*6)
To modify the admin menu just register a listener :, (*7)
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., (*8)
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, ...), (*9)
Controllers used in the the admin menu must extend the AdminMenuController, (*10)
use devilcius\AdminMenuBundle\Controller\AdminMenuController as Controller; class AuditController extends Controller { [...]
Extended menu to use with Symfony2 and sonata-admin
MIT
bundle symfony sonata-admin