我正在使用yii2-admin。所有角色和权限都添加到浏览器中。(/ localhost / yiiproject / site / admin /)
现在我的问题是我不知道如何添加updateOwnPost
。我已经阅读了this。
我没有RbacController。
这是我的代码。
$auth = Yii::$app->authManager;
// add the rule
$rule = new \app\rbac\AuthorRule;
$auth->add($rule);
// add the "updateOwnPost" permission and associate the rule with it.
$updateOwnPost = $auth->createPermission('updateOwnPost');
$updateOwnPost->description = 'Update own post';
$updateOwnPost->ruleName = $rule->name;
$auth->add($updateOwnPost);
// "updateOwnPost" will be used from "updatePost"
$auth->addChild($updateOwnPost, $updatePost);
// allow "author" to update their own posts
$auth->addChild($author, $updateOwnPost);
是否有updateOwnPost的示例?