phalcon: dispatcher调度控制器
我所理解的dispatcher调度控制器,实际上是对 router或者特定的url参数给与重组。
引用特定的类:
//add use PhalconMvcDispatcher as MvcDispatcher; use PhalconEventsManager as EventsManager;
重组参数:
$di['dispatcher'] = function(){ //创建一个事件管理 $eventsManager = new EventsManager(); //附上一个侦听者 $eventsManager->attach("dispatch:beforeDispatchLoop", function($event, $dispatcher) { $keyParams = array(); $params = $dispatcher->getParams(); //用奇数参数作key,用偶数作值 foreach ($params as $number => $value) { $keyParams[$number] =$value; } //重写参数 $dispatcher->setParams($keyParams); }); $dispatcher = new MvcDispatcher(); $dispatcher->setEventsManager($eventsManager); return $dispatcher; };
获取参数:
$this->dispatcher->getParam(参数名);