如何在 Symfony 中检索完整的角色层次结构 [英] How to retrieve full role hierarchy in Symfony

查看:31
本文介绍了如何在 Symfony 中检索完整的角色层次结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 symfony2 角色层次结构,它运行良好,但为了执行一些更改,我必须检索在我的 security.yml 中设置的 role_hierarchy.

I'm using symfony2 role hierarchy, it works well, but in order to perform some changes, i have to retrieve the role_hierarchy set up in my security.yml.

role_hierarchy:
ROLE_USER: [ROLE_ACCESS_USER, ROLE_ACCESS_DATA, ROLE_ACCESS_PRODUCT]

使用 getRoles() 只需返回 ROLE_USER,我怎么知道在我的代码中 ROLE_USER 是由 ROLE_ACCESS_USER, ROLE_ACCESS_DATA, ROLE_ACCESS_PRODUCT?

Using getRoles() just return ROLE_USER, how can i know in my code that ROLE_USER is made with ROLE_ACCESS_USER, ROLE_ACCESS_DATA, ROLE_ACCESS_PRODUCT?

感谢您的帮助.

推荐答案

可以从容器中获取层次结构:

You can get the hierarchy from the container:

$container->getParameter('security.role_hierarchy.roles')

这篇关于如何在 Symfony 中检索完整的角色层次结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆