如何在 symfony 2 中访问角色安全上下文令牌?
WelcomeAcation 的 Controller 文件中的以下代码
$usernames = $session->get('usernames');
$password = $session->get('password');
$token = new UsernamePasswordToken($usernames, $password, 'secured_area', array('ROLE_USER','CMS_CONTROL_VIEW','CMS_CONTROL_EDIT','CMS_CONTROL_LIKE'));
$this->get('security.context')->setToken($token);
我在用户中应用了服装角色以及如何获得角色中的树枝文件访问权限?
我在树枝文件 Welcome {{ app.security.getToken() }} 中有以下代码! 并打印到
UsernamePasswordToken(user="testuser", authenticated=true, roles="CMS_CONTROL_VIEW, CMS_CONTROL_EDIT, CMS_CONTROL_ADD") !
但不跑
{% if is_granted('CMS_CONTROL_EDIT') %}
echo "test";
{% endif %}
如何在树枝文件中进行角色检查?