Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // code should be sync with Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter
- private function getVariables(GuardEvent $event)
- {
- $variables = array(
- 'subject' => $event->getSubject(),
- // needed for the is_granted expression function
- 'auth_checker' => $this->authenticationChecker,
- // needed for the is_* expression function
- 'trust_resolver' => $this->trustResolver,
- );
- $token = $this->tokenStorage->getToken();
- if (null !== $token) {
- if (null !== $this->roleHierarchy) {
- $roles = $this->roleHierarchy->getReachableRoles($token->getRoles());
- } else {
- $roles = $token->getRoles();
- }
- $variables['token'] = $token;
- $variables['user'] = $token->getUser();
- $variables['roles'] = array_map(function ($role) {
- return $role->getRole();
- }, $roles);
- }
- return $variables;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement