Reputation: 17713
The KNP MenuBundle is a Symfony2 bundle for handling menus in a very dynamic way. The bundle comes out with a simple tutorial example, provided here. In the proposed example, within the Builder class, the authors supposed that a function setCurrentUri() has to be called on the $menu object. However, $menu is an instance of MenuItem class, which does not implements the above mentioned function.
To make the answer self contained, I report the code of the example class provided here:
<?php
// src/Acme/DemoBundle/Menu/Builder.php
namespace Acme\DemoBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class Builder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
{
$menu = $factory->createItem('root');
$menu->setCurrentUri($this->container->get('request')->getRequestUri());
$menu->addChild('Home', array('route' => 'homepage'));
$menu->addChild('About Me', array(
'route' => 'page_show',
'routeParameters' => array('id' => 42)
));
// ... add more children
return $menu;
}
}
PS: Notice that an important import is missing in this example, which I report in the following for sake of completeness:
use Symfony\Component\HttpFoundation\Request;
Upvotes: 1
Views: 3146
Reputation: 6636
I am also looking for the documentation update, but as a temporary solution you can set versions in deps
like these:
[KnpMenu]
git=https://github.com/KnpLabs/KnpMenu.git
version=v1.1.2
[KnpMenuBundle]
git=https://github.com/KnpLabs/KnpMenuBundle.git
target=/bundles/Knp/Bundle/MenuBundle
version=v1.1.0
Upvotes: 2