I am trying to set up Symfony with the SonataUserBundle. User registration and login works fine. When I try to call up the /profile
view, however I get the following error:
Attempted to call method "setCurrentUri" on class "Knp\Menu\MenuItem" in F:\<my project path>\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php line 91. Did you mean to call: "setCurrent"?
The last notice in the "event list" before the error is
INFO - [cms::renderBlock] block.id=53, block.type=sonata.user.block.menu
Has anyone encountered this error before and can provide information on how to resolve it?
TIA Matt
I had same issue, This is my solution that you can preserve KnpMenu V2.
-You change setCurrentUri to setCurrent (because KNP changed code) in C:\path\vendor\sonata-project\user-bundle\Block\ProfileMenuBlockService.php
-You can have this problem, Method "currentAncestor" for object "Knp\Menu\MenuItem" does not exist in Sonata
And this works for me.
What versions of
KnpMenu
andSonataBlockBundle
are you using? Please check yourcomposer.json
to be sure.The
setCurrentUri
method has been deprecated as ofKnpMenu
v. 2.0, and thecomposer.json
ofSonataBlockBundle
does not requireKnpMenu
anywhere but indev
install. So, this leads to a possibility that you could have required a fresher version ofknplabs/knp-menu-bundle
that is not yet supported by Sonata bundle.Try requiring
knplabs/knp-menu-bundle
in1.1.x
:I encountered the same problem, but downgrade to Knpmenu version 1 is not possible for our project. Because of some code update the June 16th, it is now possible to use Sonata User Bundle and Knp Menu Version 2.
Please, have a look on my composer.json :
As you can see, sonata-project/user-bundle is under dev-master version and I had to add sonata-project/datagrid-bundle in dev-master
Hope to help developpers who want want to preserve KnpMenu V2 !