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:
- pass service voter...not sure one.
- do
vote
method. - 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
Post a Comment