【发布时间】:2019-08-05 06:53:33
【问题描述】:
这是一种非常奇怪的行为,我从来没有发生过。
我的 SiteController 中有索引操作:
public function actionIndex(){
Installer::ManageInstall(); //Here I have separated code
$this->render('myView');.
}
然后在类Installer的静态函数中:
class Installer {
public static function ManageInstall(){
return Yii::$app->controller->redirect(['install']);
}
}
问题是yii完全忽略了重定向,我不知道为什么,从不重定向。
我直接试了,效果不错:
public function actionIndex(){
return Yii::$app->controller->redirect(['install']);//Here works fine
$this->render('myView');.
}
你可能会问,因为我做了这个愚蠢的例子,但实际上我已经将代码简化到最低限度,只是为了说明问题。实际上,Installer 类使用另一个条件进行重定向,我没有提出,因为它与问题无关。
我试过用这个表达方式:
Yii::$app->response->redirect(['install'])->send(); return;
和
Yii::$app->controller->redirect('install'); //without Return statement
..什么都没有
【问题讨论】:
标签: function redirect static yii2