PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 11, 2022

[FIXED] How to retrieve full role hierarchy in Symfony

 May 11, 2022     symfony     No comments   

Issue

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]

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?

thanks for helping.


Solution

You can get the hierarchy from the container:

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


Answered By - Kris Wallsmith
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing