jixinyu 2016-01-19 11:43:05 2310次浏览 1条回复 0 0 0

求为菜鸟解答下疑惑,万分感谢

  • 回复于 2016-01-21 09:00 举报

    Actions 分两种:Inline Actions 和 Standalone Actions. 前者以 action methods 形式存在,比如 actionIndex(); 后者以类的形式存在,这个类必须继承自 yii\base\Action 或其子类。

    site/error action 是以 Standalone Actions 形式存在的:

    class SiteController extends Controller
    {
    	...
    
        public function actions()
        {
            return [
                'error' => [
                    'class' => 'yii\web\ErrorAction',
                ],
            ];
        }
    
    	...
    }
    

    所以在 SiteController 内没有 actionError method.

    参考 Guide 2.0 中 Application Structure → Controllers → Creating Actions 内容。

    觉得很赞
您需要登录后才可以回复。登录 | 立即注册