Symfony\Component\Security\Authentication\Token\TokenInterface::getRoles PHP 메소드

getRoles() 공개 메소드

Returns the user roles.
public getRoles ( ) : Role[]
리턴 Role[] An array of Role instances.
    function getRoles();

Usage Example

 /**
  * {@inheritDoc}
  */
 public function getSecurityIdentities(TokenInterface $token)
 {
     $sids = array();
     // add user security identity
     $user = $token->getUser();
     if ($user instanceof AccountInterface) {
         $sids[] = UserSecurityIdentity::fromAccount($user);
     }
     // add all reachable roles
     foreach ($this->roleHierarchy->getReachableRoles($token->getRoles()) as $role) {
         $sids[] = new RoleSecurityIdentity($role);
     }
     // add built-in special roles
     if ($this->authenticationTrustResolver->isFullFledged($token)) {
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_FULLY);
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
         $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
     } else {
         if ($this->authenticationTrustResolver->isRememberMe($token)) {
             $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED);
             $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
         } else {
             if ($this->authenticationTrustResolver->isAnonymous($token)) {
                 $sids[] = new RoleSecurityIdentity(AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY);
             }
         }
     }
     return $sids;
 }
All Usage Examples Of Symfony\Component\Security\Authentication\Token\TokenInterface::getRoles