1

を使用して、を拡張し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_type']);

私は何が欠けていますか?

4

1 に答える 1

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);
    }
}
于 2012-12-16T13:33:49.913 に答える