I saw other errors about this problem. I did the same. When I try to display the menu, I get this Fatal error:
Fatal error: Call to undefined method Knp\Menu\MenuItem::setCurrentUri() in ProjectBundle/Menu/Builder.php on line 23
This is what my Builder looks like:
<?php use Knp\Menu\FactoryInterface; use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Request; class Builder extends ContainerAware { private $factory; public function __construct(FactoryInterface $factory) { $this->factory = $factory; } public function createMenu(Request $request) { $menu = $this->factory->createItem('root'); $menu->setCurrentUri($request->getRequestUri()); $menu->addChild('Home', array('route' => '_home')); $menu->addChild('About', array('route' => '_about')); $menu->addChild('Bullshit', array('route' => '_bullshit')); return $menu; } }
I looked at the error tracker on Github and it seems this problem has been fixed, but why am I having the same problem again?
I mean, when I var_dump($menu) , it clearly says that it is a MenuItem and, seeing the KnpMenu documentation, there is definitely a setCurrentUri() method for my $menu .
source share