i use Yii2 framework
this is my behaviors function in ShippingController
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
// deny all POST requests
// [
// 'actions' => ['index', 'create'],
// 'allow' => TRUE,
// ],
[
'actions' => ['index', 'create', 'init'],
'allow' => true,
'roles' => ['?'],
'matchCallback' => function ($rule, $action)
{
return $action->controller->redirect('action');
}
],
'denyCallback' => function ($rule, $action)
{
return $action->controller->redirect('not');
}
// everything else is denied
],
],
];
}
matchCallback is worked good but
indenyCallback
i have this error :
Error Call to undefined method Closure::allows()
what is my problem ???!
move denyCallback
element outside of the rules array
it needs to be on the same level with class
and rules