菜单“top-menu”未定义(Symfony2)

时间:2015-07-31 10:59:43

标签: php symfony twig

我是Symfony 2的新手。 在我被分配的项目中,我从Symfony2收到错误:

在第96行的UnitalMFrontBundle :: layout.html.twig中呈现模板(“菜单”顶级菜单“未定义。”)期间抛出异常。 < / p>

在文件“/src/Project/AdminBundle/DataFixtures/Phpcr/LoadMenuData.php”

班级

class LoadMenuData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface

有这个load()方法:

public function load(ObjectManager $dm)
{
    $basePath = $this->container->getParameter('cmf_menu.persistence.phpcr.menu_basepath');

    /** @var $menuParent Menu */
    $menuParent = $dm->find(null, $basePath);

    /*
     * TOP MENU
     */

    $topMenu = $this->createMenuNode($dm, $menuParent, 'top-menu', 'Top Menu');
    $topMenu->setChildrenAttributes(array('class' => 'header-nav'));
    $dm->persist($topMenu);

    $aboutCompanyPage = $this->createMenuNode($dm, $topMenu, 'top_about_company', 'About company', null, '/cms/simple/about_us', array('class' => 'header-nav-li'));

    $this->createMenuNode($dm, $aboutCompanyPage, 'top_about_us', 'About us', null, '/cms/simple/about_us');
    $this->createMenuNode($dm, $aboutCompanyPage, 'top_history', 'History', null, '/cms/simple/about_us/history');
    $this->createMenuNode($dm, $aboutCompanyPage, 'top_team', 'Team', null, 'show_collaborator');


    $this->createMenuNode($dm, $topMenu, 'top_license', 'Licenses', null, 'show_license', array('class' => 'header-nav-li'));
    $this->createMenuNode($dm, $topMenu, 'top_costs', 'Prices', null, 'show_prices', array('class' => 'header-nav-li'));
    $this->createMenuNode($dm, $topMenu, 'top_documents', 'Documents', null, 'show_documents', array('class' => 'header-nav-li'));
    $this->createMenuNode($dm, $topMenu, 'top_contacts', 'Contacts', null, 'unital_m_front_contacts', array('class' => 'header-nav-li'));

    $dm->flush();
}

文件“/src/Project/FrontBundle/Resources/views/layout.html.twig”中的第96行是:

{{ knp_menu_render('top-menu') }}

我搜索了许多地方寻找没有结果的解决方案。 请告知如何解决此错误。

0 个答案:

没有答案