Calling runaction between different modules in yii2

Time:2020-11-19

 

1、 Call the same controller under different action modules

// in the first mock exam of frontend\controllers\TestController\actionTest,
//Frontend / Controllers / newcontroller / actionnewaction method
Yii::$app->runAction('new/new-action');

 

2、 Call actions under different modules

// in the frontend\controllers\TestController\actionTest method, call another module.
//The method of backend / Controllers / newcontroller / actionnewaction
return (new NewController($this->id, $this->module))->runAction('new-action');