更新时间:2023-11-30 11:15:28
你在这件事上走错了路.
You've gone the wrong way about it.
这里的问题似乎是 Yii::$app->authManager
没有在应该设置的时候设置.这可能意味着您的 main.php 配置文件不包含正确的信息.它应该包含以下组件:
The issue here seems to be that Yii::$app->authManager
is not set when it should be. This probably means that your main.php configuration file does not contain the correct information.
It should contain the following component:
return [
// ...
'components' => [
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
// ...
],
];
(http://www.yiiframework.com/doc-2.0/guide-security-authorization.html#configuring-rbac-manager)
在上面链接的示例中,使用了 PhpManager,但在您的情况下,您需要使用 yii\rbac\DbManager
In the example from the link above PhpManager is used but in your case you will want to use yii\rbac\DbManager
这样做意味着您将只有一个加载的管理器,并且还将解锁所有操作过滤选项.
Doing it this way means that you will only have one loaded manager and will also unlock all action filtering options.