示例:我想允许某人仅更新特定的博客文章。
我认为规则会这样排列,但它不起作用:
$auth->createOperation('update_post_category', '', 'return ( $params["category"] == $data["category"] );');
$role = $auth->createRole('PostEditor');
$role->addChild('update_post_category');
$auth->assign('PostEditor', 'username', null, array('category' => 7));
查看 Yii 代码我明白为什么。但是我将如何实施呢?我可以为每个作业添加一个 bizrule,但我认为这相当臃肿;一定有更好的方法吧?