Reputation: 16649
So I've made a class that extends the Symfony\Bundle\FrameworkBundle\Routing\Router
and defined as my default in the config using router.class: My\Bundle\Router\Class
, but now each time I change something so simple as a route pattern or name, I get...
Fatal error: Call to a member function get() on a non-object in /.../app/cache/dev/classes.php on line 312
In that line there is:
$this->collection = $this->container->get('routing.loader')->load($this->resource, $this->options['resource_type']);
What am I missing?
Upvotes: 1
Views: 1432
Reputation: 41934
$this->container
is private in the Router
class. You can't access it directly.
You need to make it accessible explicity:
/**
* 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);
}
}
Upvotes: 2