Whenever I include the beforeAction
function event with something simple I get an error saying it has to be compatible. This does not happen on my live server only on my local one. The only difference I can think of is my local server is running PHP7 and my live one is running PHP5.6. Is that what is causing the issue? The only thing I have found that will fix it is removing it completely.
This is what my beforeAction
looks like
public function beforeAction()
{
if(Yii::$app->user->isGuest){
return $this->redirect(['site/login']);
} else {
if(strtotime(UserInfo::findOne(Yii::$app->user->Id)->active_until) < strtotime(date("Y-m-d H:i:s"))){
Yii::$app->session->setFlash('warning', 'You need an active subscription to access events.');
echo("<script>location.href = '".Url::toRoute('site/subscription')."';</script>");
exit;
//return $this->redirect(['site/subscription']);
}else {
return true;
}
}
}
I also tried this simple one to check and got the same issue
public function beforeAction()
{
if (!parent::beforeAction($action)) {
return false;
}
return true;
}
Here is the error message I get
Declaration of frontend\controllers\EventController::beforeAction() should be compatible with yii\web\Controller::beforeAction($action)