1

我有这个建设者

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;
    }
}

如何在任何操作中获取此菜单以设置当前项目?

4

1 回答 1

0

您缺少这部分逻辑:

$menu->setCurrentUri($this->container->get('request')->getRequestUri());
于 2012-10-05T06:19:16.423 回答