如何使用\ Yii :: $ classMap覆盖/扩展名称空间方法

时间:2018-01-02 07:16:16

标签: yii yii2 yii2-advanced-app yii2-basic-app yii-components

如何使用override/extend

methods命名空间\Yii::$classMap

我希望override/extend使用beforeAction($action) yii\base\Controller方法,就像这样。

namespace yii\web;
class Controller extends \yii\web\Controller
{
    public function beforeAction($action)
    {
        return parent::beforeAction($action);
    }
    // Here all the parent methods in \yii\web\Controller should be available
}

现在在backend/web/index.php

\Yii::$classMap['yii\web\Controller'] = '@common/classMaps/Controller.php';

现在在backend/controllers/MyController

namespace backend/controllers;
class MyController extends \yii\web\Controller
{
    public function actionIndex()
    {
    }
}

应该如何做?

0 个答案:

没有答案