15. Zend 路由
来源:互联网 发布:东华大学网络教育app 编辑:程序博客网 时间:2024/04/29 00:12
1. zend1\public\index.php:26
2. zend1\library\Zend\Application.php:366
3. zend1\library\Zend\Application\Bootstrap\Bootstrap.php:97
4. zend1\library\Zend\Controller\Front.php:954
5. zend1\library\Zend\Controller\Dispatcher\Standard.php:289
6.Zend1\library\Zend\Controller\Action.php:513
7.Zend1\application\controllers\TestController.php
public function dispatch(Zend_Controller_Request_Abstract $request = null, Zend_Controller_Response_Abstract $response = null) { if (!$this->getParam('noErrorHandler') && !$this->_plugins->hasPlugin('Zend_Controller_Plugin_ErrorHandler')) { // Register with stack index of 100 require_once 'Zend/Controller/Plugin/ErrorHandler.php'; $this->_plugins->registerPlugin(new Zend_Controller_Plugin_ErrorHandler(), 100); } if (!$this->getParam('noViewRenderer') && !Zend_Controller_Action_HelperBroker::hasHelper('viewRenderer')) { require_once 'Zend/Controller/Action/Helper/ViewRenderer.php'; Zend_Controller_Action_HelperBroker::getStack()->offsetSet(-80, new Zend_Controller_Action_Helper_ViewRenderer()); } /** * Instantiate default request object (HTTP version) if none provided */ if (null !== $request) { $this->setRequest($request); } elseif ((null === $request) && (null === ($request = $this->getRequest()))) { require_once 'Zend/Controller/Request/Http.php'; $request = new Zend_Controller_Request_Http(); $this->setRequest($request); } /** * Set base URL of request object, if available */ if (is_callable(array($this->_request, 'setBaseUrl'))) { if (null !== $this->_baseUrl) { $this->_request->setBaseUrl($this->_baseUrl); } } /** * Instantiate default response object (HTTP version) if none provided */ if (null !== $response) { $this->setResponse($response); } elseif ((null === $this->_response) && (null === ($this->_response = $this->getResponse()))) { require_once 'Zend/Controller/Response/Http.php'; $response = new Zend_Controller_Response_Http(); $this->setResponse($response); } /** * Register request and response objects with plugin broker */ $this->_plugins ->setRequest($this->_request) ->setResponse($this->_response); /** * Initialize router */ $router = $this->getRouter(); $router->setParams($this->getParams()); /** * Initialize dispatcher */ $dispatcher = $this->getDispatcher(); $dispatcher->setParams($this->getParams()) ->setResponse($this->_response); // Begin dispatch try { /** * Route request to controller/action, if a router is provided */ /** * Notify plugins of router startup */ $this->_plugins->routeStartup($this->_request); try { // 路由器主要负责解析一个请求并且决定什么module、controller、action被请求,并把解析的 URI 放入 $request 对象中 $router->route($this->_request); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } /** * Notify plugins of router completion */ $this->_plugins->routeShutdown($this->_request); /** * Notify plugins of dispatch loop startup */ $this->_plugins->dispatchLoopStartup($this->_request); /** * Attempt to dispatch the controller/action. If the $this->_request * indicates that it needs to be dispatched, move to the next * action in the request. */ do { // 派遣开始时,这是为 true,dispatcher 找到方法名时,也设置为 true,标志派遣结束 $this->_request->setDispatched(true); /** * Notify plugins of dispatch startup */ $this->_plugins->preDispatch($this->_request); /** * Skip requested action if preDispatch() has reset it */ if (!$this->_request->isDispatched()) { continue; } /** * Dispatch request */ try { $dispatcher->dispatch($this->_request, $this->_response); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } /** * Notify plugins of dispatch completion */ $this->_plugins->postDispatch($this->_request); } while (!$this->_request->isDispatched());//如果为 true 派遣结束 } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } /** * Notify plugins of dispatch loop completion */ try { $this->_plugins->dispatchLoopShutdown(); } catch (Exception $e) { if ($this->throwExceptions()) { throw $e; } $this->_response->setException($e); } if ($this->returnResponse()) { return $this->_response; } $this->_response->sendResponse(); }
该循环大体过程是:
a.前端控制器开始派遣循环 b.前端控制器调用派遣器 c.派遣器获取Request object请求对象,并分析它 d.派遣器从请求对象中找到对应的Action Controller动作控制器名、 e.派遣器尝试加载该动作控制器类 f.动作控制器类加载成功,派遣器实例化动作控制器类 g.派遣器器从请求对象中找到对应的Action动作名 h.派遣器将派遣标志设为true,标志着派遣完成 i.派遣器开始派遣动作控制器类中的Action方法 j.派遣动作完成,派遣器检测请求对象Request object派遣完成标识是否为false,如果是false则表示还有派遣没有完成,派遣器就再次进入派遣循环过程中;
0 0
- 15. Zend 路由
- Zend Framework教程-Zend_Controller_Router路由功能
- zend framework index路由404问题
- zend framework2 路由问题详细解答
- Zend Framework 2 入门-路由-route
- Zend Framework的路由机制代码分析
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- 路由
- linux下 ls -l 命令显示结果解释
- 一个算例 介绍 libmesh 的类
- 用 ps命令表示线程信息
- android 出现的问题
- GCD的深入理解
- 15. Zend 路由
- mysql实现自增序列
- LCD Mipi 初始化长包数据不支持 8 和 16个字节的参数传输???支持!
- tile base performance tunning
- 单片机C51 - 蜂鸣器(变频闪灯报警)
- libmesh 实现 流程
- 详解Android Studio 主题及字体修改
- Android 自定义View漫飞舞超炫超浪漫特效
- Echarts统计报表前端框架