我昨天刚刚安装了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;
}
}