KnpLabs / KnpMenuBundle

Object Oriented menus for your Symfony project.
http://knplabs.com
MIT License
1.4k stars 203 forks source link

Deprecation Message in knp-menu-bundle/src/Provider/BuilderAliasProvider.php:104 #373

Open Gemineye opened 6 years ago

Gemineye commented 6 years ago

I see this Message after rendering a menu:

User Deprecated: Passing "false" as the second argument to Symfony\Component\HttpKernel\Kernel::getBundle() is deprecated as of 3.4 and will be removed in 4.0.

stof commented 6 years ago

We cannot easily avoid this deprecation warning without breaking support for bundle inheritance. I don't have an idea yet to avoid triggering it in case inheritance is not used (I'm not even sure it is possible).

Our code is already compatible with newer versions not supporting this attribute though.

slunak commented 6 years ago

I was getting the same depreciation notice in 3.4 and was able to get rid of it. I was calling the menus in views using the following:

{{ knp_menu_render('AppBundle:Builder:dashboardAccountMenu', {'template': ':menu:menu.html.twig'}) }}

The Builder class was not registered as a Service. Following the documentation I registered MenuBuilder as a Service:

Creating Menu Builders as Services

And now calling menus as following (using menu alias):

{{ knp_menu_render('dashboard_account_menu', {'template': ':menu:menu.html.twig'}) }}

Hope this can help someone.