, 나는 심포니의 새로운 프로젝트를 설치하고 난 다음 명령을 사용 knpMenuBundle 추가 여기에 언급 된 바와 같이 http://symfony.com/doc/master/bundles/KnpMenuBundle/menu_builder_service.html심포니 KnpMenuBundle 보여주는 오류 [서비스 MenuBuilder는] <pre><code>composer require knplabs/knp-menu-bundle "^2.0" </code></pre> <p></p>가 지금은 정확히 모든 것을 다음,
이 라인은 default/index.html.twig 파일에 {{ knp_menu_render('main') }}
이 추가되었습니다.
내가 프로젝트를 실행할 때 이제 그 날이 오류를 보여
[InvalidArgumentException]
Menu builder services must be public but "app.menu_builder" is a private service.
config.yml
knp_menu:
# use "twig: false" to disable the Twig extension and the TwigRenderer
twig:
template: KnpMenuBundle::menu.html.twig
# if true, enables the helper for PHP templates
templating: false
# the renderer to use, list is also available by default
default_renderer: twig
MenuBuilder.php
<?php
namespace AppBundle\Menu;
use Knp\Menu\FactoryInterface;
class MenuBuilder
{
private $factory;
/**
* @param FactoryInterface $factory
*
* Add any other dependency you need
*/
public function __construct(FactoryInterface $factory)
{
$this->factory = $factory;
}
public function createMainMenu(array $options)
{
$menu = $this->factory->createItem('root');
$menu->addChild('Home', array('route' => 'homepage'));
// ... add more children
return $menu;
}
}
services.yml
app.menu_builder:
class: AppBundle\Menu\MenuBuilder
arguments: ["@knp_menu.factory"]
tags:
- { name: knp_menu.menu_builder, method: createMainMenu, alias: main } # The alias is what is used to retrieve the menu
어떻게 해결할 수 있습니까? 어떤 도움이라도 대단히 감사합니다. 감사합니다