liuggio / KnpMenuExtensionBundle

[USE KNP-MENU-BUNDLE THEY ADDED THE YML FUNCTIONALITY ]Extends the KnpMenu, you can configure, create or add nodes to the menu from any bundle, only adding rows in the bundle's config file
4 stars 0 forks source link

Hey, we doing same thing #1

Open zerkalica opened 12 years ago

zerkalica commented 12 years ago

I restored my menu bundle on top of knp menu: https://github.com/zerkalica/MillwrightMenuBundle

MillwrightMenuBundle extends base functionality of KnpMenuBundle and adds configuration, route, translation, context, roles, acls, annotations and many other.

I think about your event-based configuration, why do not use one menu builder service, all other bundles can configure and add any option to this menu builder, integration on config-level, not events ?

say:

#first bundle

millwright_menu: #menu builder service
    tree:
        main_menu: # menu container name
            user_view: <options> #menu item
            user_edit: <options>
#second bundle

millwright_menu:
    tree:
        main_menu:
            article_view: <options>
            article_edit: <options>

We can add numeric order parameter to each menu item, and sort it.

liuggio commented 12 years ago

Hi, thanks for your interest, depends, how did you implement the builder? how could the 2nd bundle inject his parameters into the constructor elegantly?

zerkalica commented 12 years ago

I rewrite twig helpers for using menu builder instead of menu provider. All other bundles can change menu builder config through config files using import directive.

    - { resource: budnle1/menu.yml }
    - { resource: budnle2/menu.yml }

It's no good way and i think about it. It's possible to move options to parameters section of service container, so other services can modify it or provide config options service with tag and scan them on complile pass.

zerkalica commented 12 years ago

My draft version of menu items ordering. I use tagged services with order attribute and compiler pass, which sorts and merges all options from services into single array and replaces menu builder argument.

https://github.com/zerkalica/MillwrightMenuBundle/blob/master/DependencyInjection/Compiler/MenuBuilderOptionsPass.php

https://github.com/zerkalica/MillwrightMenuBundle/blob/master/Resources/config/services.xml#L60

So, any bundle can modify any menu item in hierarchy.