我一直在研究Symfony2代码,我无法弄清楚如何在不扩展/覆盖ControllerResolver类的功能的情况下找出正确的控制器。我不认为默认的ControllerResolver能够找到像BundleName这样的控制器:Bundle:action to controller。
答案 0 :(得分:0)
控制器在HTTPKernel类中解析(https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/HttpKernel.php)。这就是那里发生的事情
// load controller
if (false === $controller = $this->resolver->getController($request)) {
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". Maybe you forgot to add the matching route in your routing configuration?', $request->getPathInfo()));
}
解析控制器后,控制器类将位于请求的__controller属性中