Symfony 如何正确覆盖默认路由器?
因此,我创建了一个类来扩展Symfony 如何正确覆盖默认路由器?,symfony,Symfony,因此,我创建了一个类来扩展Symfony\Bundle\FrameworkBundle\Routing\Router 并在配置中使用router.class:my\Bundle\router\class定义为我的默认设置,但现在每次更改路由模式或名称这样简单的内容时,我都会 致命错误:对第312行的/../app/cache/dev/classes.php中的非对象调用成员函数get() 在这方面有: $this->collection=$this->container->get('routin
Symfony\Bundle\FrameworkBundle\Routing\Router
并在配置中使用router.class:my\Bundle\router\class
定义为我的默认设置,但现在每次更改路由模式或名称这样简单的内容时,我都会
致命错误:对第312行的/../app/cache/dev/classes.php中的非对象调用成员函数get()
在这方面有:
$this->collection=$this->container->get('routing.loader')->load($this->resource,$this->options['resource\u type']);
我缺少什么?
$this->container
在路由器
类中是私有的。您不能直接访问它
您需要明确地使其可访问:
/**
*路由器
*/
类路由器扩展了BaseRouter
{
受保护的集装箱;
/**
*构造器。
*
*@param ContainerInterface$container一个ContainerInterface实例
*@param mixed$resource要加载的主资源
*@param array$options一组选项
*@param RequestContext$context上下文上下文
*@param array$默认为默认值
*/
公共函数_构造(ContainerInterface$container,$resource,array$options=array(),RequestContext$context=null,array$defaults=array())
{
$this->container=$container;
父项::_构造($container、$resource、$options、$context、$defaults);
}
}
谢谢大家!这就是问题所在,“私人”。。。它快把我逼疯了,我没有看到它。