我昨天刚安装的apc我现在收到此错误:
FatalErrorException: Error: Cannot instantiate abstract class
ACME\WebBundle\Menu\MenuBuilder in
/var/www/app/cache/dev/appDevDebugProjectContainer.php line 743
在那一行有:
protected function getEposMain_MenuBuilderService()
{
return $this->services['epos_main.menu_builder'] = new \ACME\WebBundle\Menu\MenuBuilder($this->get('knp_menu.factory'));
}
有谁知道这是什么意思以及我可以用它做什么?
服务.yml
services:
epos_main.menu_builder:
class: ACME\WebBundle\Menu\MenuBuilder
arguments: ["@knp_menu.factory"]
epos_main.menu.main:
class: Knp\Menu\MenuItem # the service definition requires setting the class
factory_service: epos_main.menu_builder
factory_method: createMainMenu
arguments:
- @request
- @twig
- 'ACMEWebBundle:Menu:menu.html.twig'
scope: request # needed as we have the request as a dependency here
tags:
- { name: knp_menu.menu, alias: main } # The alias is what is used to retrieve the menu
epos.twig.epos_extension:
class: ACME\WebBundle\Twig\ePOSTwigExtension
tags:
- { name: twig.extension }
一些 MenuBuilder 类代码:
namespace ACME\WebBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\HttpFoundation\Request;
class MenuBuilder
{
private $factory;
/**
* @param FactoryInterface $factory
*/
public function __construct(FactoryInterface $factory)
{
$this->factory = $factory;
}
public function createMainMenu(Request $request)
{
$menu = $this->factory->createItem('root');
$menu->setChildrenAttribute('class', 'nav');
...
...
return $menu;
}
}
这个错误是不言自明的。你不能实例化根据 OOP 规则的抽象类!
Your MenuBuilder
is an abstract
类,并且您正在尝试实例化new
关键字是不可能的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)