Yii2 獲取模組名 控制器名 方法名

2021-10-04 06:56:21 字數 568 閱讀 1878

yii2 獲取模組名、控制器名、方法名

在檢視中:

模組名 $this->context->module->id

控制器名 $this->context->id

方法名 $this->context->action->id

在控制器中

模組名 yii::app

−>co

ntro

ller

−>mo

dule

−>id

;控制器

名yii

::

app−

>co

ntro

ller

−>mo

dule

−>id

;控制器

名yii

::在控制器的 beforeaction 方法中(方法接收$action引數)

模組名 $action->controller->module->id;

控制器名 $action->controller->id;

方法名 $action->id;

————————————————

Yii2 獲取模組名 控制器名 方法名

yii2 獲取模組名 控制器名 方法名 在檢視中 模組名 this context module id 控制器名 this context id 方法名 this context action id在控制器中 或模組名 this module id 控制器名 this id 方法名 this act...

Yii2 獲取模組名 控制器名 方法名

yii2 獲取模組名 控制器名 方法名 在檢視中 模組名 this context module id 控制器名 this context id 方法名 this context action id 在控制器中 或模組名 this module id 控制器名 this id 方法名 this ac...

Yii2 獲取模組名 控制器名 方法名

yii2 獲取模組名 控制器名 方法名 在檢視中 模組名 this context module id 控制器名 this context id 方法名 this context action id 在控制器中 或模組名 this module id 控制器名 this id 方法名 this ac...