我正在尝试创建嵌套角色,其中开发人员是可以访问所有控制器/操作的角色,这是我的家谱布局:
'role_providers' => array(
'BjyAuthorize\Provider\Role\Config' => array(
'guest' => array('children' => array(
'programador' => array(
'children'=>array(
'administration'=>array('children'=>array('developer'=>array())),
)
),
'conclidiador' => array(
'children'=>array(
'administration'=>array('children'=>array('developer'=>array())),
)
),
'tesorero' => array(
'children'=>array(
'administration'=>array('children'=>array('developer'=>array())),
)
),
)),
),
),
这不起作用。
如果我只留下一个,它的工作正常。
'role_providers' => array(
'BjyAuthorize\Provider\Role\Config' => array(
'guest' => array('children' => array(
'programador' => array(
'children'=>array(
'administration'=>array('children'=>array('developer'=>array())),
)
),
)),
),
),
我希望开发人员可以访问管理层,然后是其他programador,conclidiador,tesorero在同一级别和最后的访客。
答案 0 :(得分:0)
我正在尝试类似的东西,但在配置文件中有不同的风格:
'BjyAuthorize\Provider\Role\Config' => [
'guest' => [],
'user' => ['children' => [
'admin' => [],
'member' => ['children' => [
'membervip' => []
]],
'merchant' => ['children' => [
'merchantvip' => []
]],
'player' => ['children' => [
'playerplus' => []
]]
]],
],
我还必须调整表'user_role'以对应上面的布局/配置有正确的'user_role'。'parent_id'值如上
因此,我认为你需要这样的东西:
'BjyAuthorize\Provider\Role\Config' => [
'guest' => [],
'user' => ['children' => [
'programador' => [],
'conclidiador' => [],
'tesorero' => [],
'administrator' => ['children' => [
'developer' => []
]]
]],
],
那是父母'用户'与所有人的水平相同。然后在路由/控制器gaurds中定义该级别的权限。 'user'是对所有子角色的基本访问权限,然后拆分为'administrator'