I want to create a navigation list in one of my bundle (the “base” bundle) that will include a couple of options. How can I allow other bundles to add to that list?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would like a more detailed question but here it goes anyway.
First, check KnpBundles for bundles that already provide menu features. Something like KnpMenuBundle. Looks good? Fine, use it.
Nothing fits your taste? Then roll your own. I would go with something like this:
Create a
NavListManagerclass in the base bundle and aAbstractNavListclass to be extended by every other bundle that adds options to the navigation list.Each bundle should provide a
NavListclass extendingAbstractNavList. Theses classes should provide navigation list options.In your base bundle edit the
DependencyInjection\<MyBundle>Extension::load()method to lookup aNavListclass in each of your bundles using$container->getParameter('kernel.bundles'). Include every collected class inNavListManager.Now call something like
$navman->render()in the template to generate the navigation list.