Answer the question
In order to leave comments, you need to log in
How to make those work on the site on / off through catchAll?
Hello everyone, I have a question about the implementation on an already working site.
I know that there is in the config ,
How to make it possible to simply change one field in the database, for example, with the name site_offline 0 | 1
and if 1 then in the config it will be catchAll if 0 then it is not there and the site works. in normal mode. 'catchAll' => ['site/offline']
Answer the question
In order to leave comments, you need to log in
You can use as Dmitry suggested ,
'on afterAction' => function ($event) {
if ( Yii::$app->siteSettings->get('SITE.OFF_LINE') == 'on' ) {
if ( !Yii::$app->user->isGuest && !Yii::$app->user->can('admin') ) {
Yii::$app->user->logout();
return Yii::$app->response->redirect([ 'offline/off-mode' ]);
}
}
return false;
},
but move this code into a behavior. It is better not to leave it in the config. Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question