yii框架的执行过程

作者:zccst


二、controllers里的$this和models里的$this含义是不一样的。
在controllers里,可以$this->current_user,因为current_user已经在Controller.php里定义。
而在models里,$this是AR类。


一、分析一个具体的yii执行过程
#11 ../protected/controllers/OutsourceController.php(206): OutsourceController->doAction('suspend')
#12 ../Yii-1.1/framework/web/actions/CInlineAction.php(32): OutsourceController->actionSuspend()
#13 ../Yii-1.1/framework/web/CController.php(300): CInlineAction->run()
#14 ../Yii-1.1/framework/web/filters/CFilterChain.php(129): CController->runAction(Object(CInlineAction))  //运行Action
#15 ../protected/components/Controller.php(83): CFilterChain->run()
#16 ../Yii-1.1/framework/web/filters/CInlineFilter.php(59): Controller->filterAccessAuth(Object(CFilterChain))//自定义Controller
#17 ../Yii-1.1/framework/web/filters/CFilterChain.php(126): CInlineFilter->filter(Object(CFilterChain))
#18 ../Yii-1.1/framework/web/CController.php(283): CFilterChain->run()
#19 ../Yii-1.1/framework/web/CController.php(257): CController->runActionWithFilters(Object(CInlineAction), Array)
/*-------------------------------------------------------------------------
在CController.php的run('suspend')方法中,执行了
if($parent->beforeControllerAction($this,$action))
{
$this->runActionWithFilters($action,$this->filters());//带过滤的运行action。也即运行controller的时候还没加入过滤。
$parent->afterControllerAction($this,$action);
}
在runActionWithFilters方法中又执行了CFilterChain::create($this,$action,$filters)->run();
该方法先create,再run,在run方法中又执行了$filter->filter($this); 在filter方法中
$method='filter'.$this->name;
$filterChain->controller->$method($filterChain);
----------------------------------------------------------------------------*/
#20 ../Yii-1.1/framework/web/CWebApplication.php(320): CController->run('suspend')                   
#21 ../Yii-1.1/framework/web/CWebApplication.php(120): CWebApplication->runController('outsource/suspend') //运行Controller
#22 ../Yii-1.1/framework/base/CApplication.php(135): CWebApplication->processRequest()
#23 /url/index.php(28): CApplication->run()

你可能感兴趣的:(yii框架)