我使用Yii2框架
这是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运作良好,但
denyCallback
中的我有这个错误:
错误 调用未定义的方法Closure :: allows()
我的问题是什么???!
答案 0 :(得分:3)
将denyCallback
元素移出规则数组之外
它需要与class
和rules