2012-12-16 49 views
1

所以我做了扩展Symfony\Bundle\FrameworkBundle\Routing\Router 一个类,定义为使用router.class: My\Bundle\Router\Class我在配置默认的,但现在我每次改变的东西作为路由模式或名称,我得到这么简单的时间...如何正确覆盖默认路由器?

Fatal error: Call to a member function get() on a non-object in /.../app/cache/dev/classes.php on line 312

在该行有:

$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']); 

我缺少什么?

回答

2

$this->containerRouter类中是私有的。你不能直接访问它。

你需要使它显式访问:

/** 
* Router 
*/ 
class Router extends BaseRouter 
{ 
    protected $container; 

    /** 
    * Constructor. 
    * 
    * @param ContainerInterface $container A ContainerInterface instance 
    * @param mixed    $resource The main resource to load 
    * @param array    $options An array of options 
    * @param RequestContext  $context The context 
    * @param array    $defaults The default values 
    */ 
    public function __construct(ContainerInterface $container, $resource, array $options = array(), RequestContext $context = null, array $defaults = array()) 
    { 
     $this->container = $container; 

     parent::__construct($container, $resource, $options, $context, $defaults); 
    } 
} 
+0

感谢你加入一个解决方案,@meze! –

+0

谢谢你们!这是问题,“私人”......这让我疯狂,我没有看到它。 – coma