It’s a very strange behavior,
I have the index action in my SiteController :
public function actionIndex(){
Installer::ManageInstall(); //Here I have separated code
$this->render('myView');.
}
Then in the static function of the class Installer:
class Installer {
public static function ManageInstall(){
if(1=1){ //condition is a some condition to evaluate, to try I
// put 1=1
return Yii::$app->controller->redirect(['install']);
}else{
return;
}
}
}
The problem is that yii totally ignores the redirection,and I do not know why, never redirect.
I tried directly and it work’s :
public function actionIndex(){
return Yii::$app->controller->redirect(['install']);//Here works fine
$this->render('myView');.
}
You may ask, because I make this silly example, but in reality I have simplified code to the minimum just to show the problem. Actually the Installer class, redirects using another condition, which I have not put because it has nothing to do with the problem.
I tried with this expressions:
Yii::$app->response->redirect(['install'])->send(); return;
and
Yii::$app->controller->redirect('install'); //without Return statement
…and nothing