Extends a KnpMenu from a Symfony Bundle

288 views Asked by At

I am using Sylius as a shop Symfony bundle, and I would like to extend the KnpMenu used in "/admin" path of this bundle. In Sylius, the menu is made from a service :

 <service id="sylius.menu_builder.admin.main" class="Sylius\Bundle\AdminBundle\Menu\MainMenuBuilder"
                 parent="sylius.menu_builder" public="false">
        </service>
        <service id="sylius.menu.admin.main" class="Knp\Menu\MenuItem">
            <factory service="sylius.menu_builder.admin.main" method="createMenu" />
            <tag name="knp_menu.menu" alias="sylius.admin.main" />
        </service>

Is there a way to add an entry in this menu from my own Bundle ?

Thanks for your help !

1

There are 1 answers

1
Ivan Matas On BEST ANSWER

Yes, you have to create MenuListener, add child elements in there, and register it as a service. You have it explained in the documentation: http://docs.sylius.org/en/latest/customization/menu.html

Good luck!