Yii2 get module name, controller name, method name [version 2.0]

Yii2 gets the module name, controller name and method name in the view: module name $this->context->module->id controller name $this->context->id method name $this->context->action- >id in the controller module name Yii::$app->controller->module->id; controller name Yii::$app->controller->id method name Yii::$app->controller->action ->id; or module name $this->module->id; controller name $this->id; method name $this->action->id; in the beforeAction method of the controller (the method receives the $action parameter) Module name $action->controller->module->id; Controller name $action->controller->id; Method name $action->id;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326120127&siteId=291194637