symedit/menu-bundle

There is no license information available for the latest version (v0.11) of this package.

Symfony2 Bundle for managing menus with multiple sources

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

v0.11 2015-09-23 20:44 UTC

This package is auto-updated.

Last update: 2024-10-24 09:54:02 UTC


README

The main point of this bundle is to allow multiple other bundles to construct a single menu. The way this is done is by adding tags to the DI container and then running the root node of the menu through each of the builders.

This bundle also adds a way to run menu extension after the menu has been built which can allow you to remove nodes before the menu is rendered.

Registering a Builder

<service id="symedit_blog.symedit.menu" class="%symedit_blog.symedit.menu.class%">
    <tag name="symedit_menu.builder" menu="symedit_admin" priority="16" />
</service>

menu is required on the tag. If there are multiple tags with the same menu name then they will be built according to priority (higher priority means the that builder will execute first, default is 0).

Extensions

Security Extension

You may add is_granted information to menu items and they will be removed if the user does not have these permissions:

$menu->addChild('Label', array(
    'extras' => array(
        'is_granted' => 'ROLE_ADMIN'
    ),
));

Remove Empty Dropdowns

You can use remove_leaf to remove any dropdowns with no children. We suggest having a main menu builder run first to create each of the dropdowns that your other bundles may use so they won't have to check if they exist first and create them if not. This solves the problem of no other builders using that dropdown:

$menu->addChild('Dropdown', array(
    'dropdown' => true, // From MopaBootstrapBundle
    'extras' => array(
        'remove_leaf' => true,
    ),
));