0

I am currently working in AdminController.php where I need to check the role of the the logged in user. In the UserInterface.php of FOSUserBundle I found the public function hasRole(), which does exactly what I need. But in comments it's said to never use the function. Instead the author recommend to use $authorizationChecker->isGranted('ROLE_USER'); but on what do I have to call isGranted? Is there any method like $this->getUser() which returns sth. of type AuthorizationChecker?

This is perfectly working: $this->getUser()->hasRole('ROLE_ADMIN')

Ccenter
  • 107
  • 10

0 Answers0