src/Authorization/SecuredAccessTrait.php
public function isRoleAllowed($role, $attribute = 'access')
    {
        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->isRoleAllowed($r, $attribute)) {
                    return true;
                }
            }
            return false;
        } else {
            $roleStr = (string) $role;
            $attrStr = (string) $attribute;
            if (isset($this->allowedRoles[$roleStr])) {
                return
                    (isset($this->allowedRoles[$roleStr][$attrStr]) ?
                    $this->allowedRoles[$roleStr][$attrStr] : false) ||
                    (isset($this->allowedRoles[$roleStr]['any']) ?
                    $this->allowedRoles[$roleStr]['any'] : false);
            }
            return false;
        }
    }
public function isRoleAllowed($role, $attribute = 'access')
    {
        if (is_array($role)) {
            foreach ($role as $r) {
                if ($this->isRoleAllowed($r, $attribute)) {
                    return true;
                }
            }
            return false;
        } else {
            $roleStr = (string) $role;
            $attrStr = (string) $attribute;
            if (isset($this->allowedRoles[$roleStr])) {
                return
                    (isset($this->allowedRoles[$roleStr][$attrStr]) ?
                    $this->allowedRoles[$roleStr][$attrStr] : false) ||
                    (isset($this->allowedRoles[$roleStr]['any']) ?
                    $this->allowedRoles[$roleStr]['any'] : false);
            }
            return false;
        }
    }
public function isRoleAllowed ( $ role , $ attribute = 'access' ) { if ( is_array ( $ role ) ) { foreach ( $ role as $ r ) { if ( $ this -> isRoleAllowed ( $ r , $ attribute ) ) { return true ; } } return false ; } else { $ roleStr = ( string ) $ role ; $ attrStr = ( string ) $ attribute ; if ( isset ( $ this -> allowedRoles [ $ roleStr ] ) ) { return ( isset ( $ this -> allowedRoles [ $ roleStr ] [ $ attrStr ] ) ? $ this -> allowedRoles [ $ roleStr ] [ $ attrStr ] : false ) || ( isset ( $ this -> allowedRoles [ $ roleStr ] [ 'any' ] ) ? $ this -> allowedRoles [ $ roleStr ] [ 'any' ] : false ) ; } return false ; } }
Check if a specific user role is allowed to access
@param string $role User role
@param string $attribute Attribute
@return bool
Check if a specific user role is allowed to access