Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. private function getVariables(GuardEvent $event)
  2. {
  3. $token = $this->tokenStorage->getToken();
  4.  
  5. if (null === $token) {
  6. throw new \Exception("No token is set")
  7. }
  8.  
  9. if (null !== $this->roleHierarchy) {
  10. $roles = $this->roleHierarchy->getReachableRoles($token->getRoles());
  11. } else {
  12. $roles = $token->getRoles();
  13. }
  14.  
  15. $variables = array(
  16. 'token' => $token,
  17. 'user' => $token->getUser(),
  18. 'subject' => $event->getSubject(),
  19. 'roles' => array_map(function ($role) {
  20. return $role->getRole();
  21. }, $roles),
  22. // needed for the is_granted expression function
  23. 'auth_checker' => $this->authenticationChecker,
  24. // needed for the is_* expression function
  25. 'trust_resolver' => $this->trustResolver,
  26. );
  27.  
  28. return $variables;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement