我有这个建设者
namespace Telnet\CSSBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
class Builder extends ContainerAware
{
public function mainMenu(FactoryInterface $factory, array $options)
{
$menu = $factory->createItem('Main Menu');
$menu->addChild('Главная', array('route' => 'pages_index'));
$menu->addChild('Форум', array('uri' => '/forum'));
$menu->addChild('Демки', array('route' => 'pages_dem'));
$menu->addChild('SourceBans', array('uri' => '/sourcebans'));
$menu->addChild('HLStatsX', array('uri' => '/hlstatx'));
return $menu;
}
}
如何在设置当前项目的任何操作中获取此菜单?
答案 0 :(得分:0)
你缺少这部分逻辑:
$menu->setCurrentUri($this->container->get('request')->getRequestUri());