duancaoqin6683 2012-04-17 03:41 采纳率: 0%
浏览 16

Symfony2如何在不扩展ControllerResolver的情况下找到正确的控制器?

I've been looking at Symfony2 code and I can't figure out how it figures out the correct controller to use without extending/overriding the functions of the ControllerResolver class. I don't think the default ControllerResolver is able to find the controller for something like BundleName:Bundle:action to a controller.

  • 写回答

1条回答 默认 最新

  • dongyong2063 2012-04-17 12:39
    关注

    Controller is resolved in the HTTPKernel Class (https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpKernel/HttpKernel.php) . This is what happens there

        // 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()));
        }
    

    Once the controller is resolved , the controller class will be there in the __controller property of the request

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度