symfony2admingenerator / GeneratorBundle

Admingenerator for Symfony. Parse YAML files to build customized backend.
MIT License
67 stars 29 forks source link

How to / menu #239

Closed lionelbzv closed 8 years ago

lionelbzv commented 8 years ago

Recent lib update breaks something in menu construction: could you please explain the new way to override the main menu?

The cookbook way gives me now:

Type error: Argument 1 passed to Admingenerator\GeneratorBundle\Menu\AdmingeneratorMenuBuilder::__construct() must implement interface Knp\Menu\FactoryInterface, none given, called in /var/www/myproject/vendor/knplabs/knp-menu-bundle/Provider/BuilderAliasProvider.php on line 121

Thanks

lionelbzv commented 8 years ago

here is my way, hope it's the good one :)

custom base_admin.html.twig

            {% block sidebar_menu %}
                {{ knp_menu_render('admingen_mysidebar') }}
            {% endblock %}

services.yml

    admingen.menu.default_builder:
        class: AdminBundle\Menu\AdminMenu
        arguments:
            - @knp_menu.factory
            - @request_stack
            - AdminHomepage
        tags:
            - { name: knp_menu.menu_builder, method: sidebarMenu, alias: admingen_mysidebar }
sescandell commented 8 years ago

Hi @Lionel09

Yes, you need to create your menu as a service and define the right alias. This comes from #221 if I'm not wrong.

Documentation should be updated thanks to #223