Nette\Security\User::getRoles PHP Method

getRoles() public method

Returns a list of effective roles that a user has been granted.
public getRoles ( ) : array
return array
    public function getRoles()
    {
        if (!$this->isLoggedIn()) {
            return [$this->guestRole];
        }
        $identity = $this->getIdentity();
        return $identity && $identity->getRoles() ? $identity->getRoles() : [$this->authenticatedRole];
    }

Usage Example

コード例 #1
0
 private function extractRoles()
 {
     $userRoles = $this->user->getRoles();
     if ($this->roleHierarchy) {
         return $this->roleHierarchy->getReachableRoles($userRoles);
     }
     return $userRoles;
 }
All Usage Examples Of Nette\Security\User::getRoles