kevintweber / KtwDatabaseMenuBundle

Symfony bundle for extending KnpMenu to store menu items in a database.
MIT License
12 stars 5 forks source link

Add missing example as a service #18

Open emulienfou opened 7 years ago

emulienfou commented 7 years ago

Hi, I think it would be great to add some documentation in relation to add menu as a service like explained in the official KnpMenu documentation: Creating Menus as Services.

Here is an example of my configuration:

app.menu_builder:
        class: AppBundle\Menu\MenuBuilder
        arguments: ['@ktw_database_menu.factory', '@doctrine.orm.entity_manager']

    app.main_menu:
        class: Knp\Menu\MenuItem # the service definition requires setting the class
        factory: ["@app.menu_builder", createMainMenu]
        tags:
            - { name: knp_menu.menu, alias: main } # The alias is what is used to retrieve the menu

If it can help people to do the same and not spent hours to find the right configuration!

kevintweber commented 7 years ago

You're right. This would help. (I take it that you "spent hours to find the right configuration". If so, I sympathize.)

I'll work on this sometime, or you can submit a pull request to augment the documentation. Either way this will get into the docs eventually.

Thanks, Kevin

emulienfou commented 7 years ago

Hi Kevin, I'll send you a PR with the updated documentation with this example as soon as possible.