[b]Call to a member function checkAccess() on a non-object
[/b]
I dont Know why i get this error, But Last week this piece of code works. I am using Yii 2.0.6.
public static function validate(){
if ( !Yii::$app->user->isGuest) {
$urlData = Yii::$app->controller->id."/".Yii::$app->controller->action->id;
if ( !Yii::$app->user->can($urlData) ) {
Yii::$app->getResponse()->redirect(Yii::$app->request->referrer);
//throw new ForbiddenHttpException();
}
}
return true;
}
Above function runs in beforeAction of every controllers actions.
6705