getRoles() public method

public getRoles ( )
Example #1
0
 public function getRoles()
 {
     $user = $this->getUser();
     if ($user instanceof UserInterface) {
         return $this->getUserRoles($user);
     }
     return parent::getRoles();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     if ($this->_user) {
         $roles = array();
         foreach ($this->_user->getRoles() as $_role) {
             $roles[] = new \Symfony\Component\Security\Core\Role\Role($_role);
         }
         return $roles;
     }
     return parent::getRoles();
 }
Example #3
0
 public function update(AbstractToken $token)
 {
     $usurpator = false;
     $roles = $token->getRoles();
     foreach ($roles as $role) {
         if ($role->getRole() === 'ROLE_PREVIOUS_ADMIN') {
             return;
         }
         //May be better to check the class of the token.
         if ($role->getRole() === 'ROLE_USURPATE_WORKSPACE_ROLE') {
             $usurpator = true;
         }
     }
     if ($usurpator) {
         $this->updateUsurpator($token);
     } else {
         $this->updateNormal($token);
     }
 }