How to get current module object from model in Yii2
we can identify the module,controller and action method as follows in yii2Yii::$app->controller->module->id;
(For Getting Module ID) Yii::$app->controller->id;
(For Getting Controller ID)Yii::$app->controller->action->id;
(For Getting Controller action ID)
You can use className()
to obtain the class name.
$yourModule = yourPath\YourModule::className();
Or for getting the module id you can use:
Yii::$app->controller->module->id;