Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. // code should be sync with Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter
  2.     private function getVariables(GuardEvent $event)
  3.     {
  4.         $variables = array(
  5.             'subject' => $event->getSubject(),
  6.             // needed for the is_granted expression function
  7.             'auth_checker' => $this->authenticationChecker,
  8.             // needed for the is_* expression function
  9.             'trust_resolver' => $this->trustResolver,
  10.         );
  11.  
  12.         $token = $this->tokenStorage->getToken();
  13.         if (null !== $token) {
  14.             if (null !== $this->roleHierarchy) {
  15.                 $roles = $this->roleHierarchy->getReachableRoles($token->getRoles());
  16.             } else {
  17.                 $roles = $token->getRoles();
  18.             }
  19.  
  20.             $variables['token'] = $token;
  21.             $variables['user']  = $token->getUser();
  22.             $variables['roles'] = array_map(function ($role) {
  23.                 return $role->getRole();
  24.             }, $roles);
  25.         }
  26.  
  27.         return $variables;
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement