php - Symfony voter: how do I check a user's role? -


i have posts owned specific user. i've created voter check if user owns post, want admins (ie, role_admin , above) able access posts.

i've followed instructions (and copied code) on how use voters check user permissions cookbook entry. i'm wondering how check. ideas:

  1. pass service voter...not sure one.
  2. do vote method.
  3. don't check in voter, inside controller (ie, don't call voter check if they're admin).

using $token, passed in vote method, can retrieve $user. check role $user->getroles() method.

<?php  $user = $token->getuser(); $user->getroles(); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -