Get an array of fully qualified user roles

@param mixed $roles  Comma-separated list of roles or array of roles

@return array Array of roles
762873
public static function parseRoles($roles)
    {

        if (!is_array($roles)) {
            $roles = explode(',', $roles);
        }
        $parsedRoles = array();
        foreach ($roles as $role) {
            $role = trim($role);
            if (!empty($role)) {
                if (substr($role, 0, 4) !== 'urn:') {
                    $role = 'urn:lti:role:ims/lis/' . $role;
                }
                $parsedRoles[] = $role;
            }
        }

        return $parsedRoles;

    }
429895
private function getAbilities($role)
    {
        $abilities = [];
        foreach (config('auth.acl') as $ability => $roles) {
            if (in_array($role, $roles)) {
                $abilities[] = $ability;
            }
        }

        return $abilities;
    }
177037
public function hasRoles($roles)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($roles)) {
            $roles = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($roles, $this->roles)) === count($roles);
    }
309277
private static function get_role( $role ) {
		global $wp_roles;

		$role_obj = $wp_roles->get_role( $role );

		if ( ! $role_obj ) {
			WP_CLI::error( "'{$role}' role not found." );
		}

		return $role_obj;
	}
865808
public function translateToRoleIds($roles)
    {
        if (!is_array($roles)) {
            if ($roles) {
                $roles = explode(",", $roles);
            } else {
                $roles = array();
            }
        }

        $lookup = array_flip($this->_roleTranslations);

        foreach ($roles as $key => $role) {
            if (isset($lookup[$role])) {
                $roles[$key] = $lookup[$role];
            }
        }

        return $roles;
    }
1303757
public function hasAllRoles($roles): bool
    {
        if (is_string($roles) && false !== strpos($roles, '|')) {
            $roles = $this->convertPipeToArray($roles);
        }

        if (is_string($roles)) {
            return $this->roles->contains('name', $roles);
        }

        if ($roles instanceof Role) {
            return $this->roles->contains('id', $roles->id);
        }

        $roles = collect()->make($roles)->map(function ($role) {
            return $role instanceof Role ? $role->name : $role;
        });

        return $roles->intersect($this->roles->pluck('name')) == $roles;
    }
767992
public function getRoles(string $role): array
    {
        if(!\in_array($role, $this->roles))
            throw new UndefinedRoleException("This role '{$role}' is not registered into RoleHierarchy");
        
        return isset($this->map[$role]) ? \array_merge([], [$role], $this->map[$role]) : [$role];
    }
577817
public function getByRoles(array $rolesIds)
    {
        return $this->model->whereHas('roles', function ($query) use ($rolesIds) {
            $query->whereIn('id', $rolesIds);
        })->get();
    }
303776
public function roleLoadPermissions($roles)
    {
        if (!$roles) {
            return false;
        }
        $multi = is_array($roles);
        if (!$multi) {
            $roles = [$roles];
        }
        $permissions_ids = [];

        foreach ($roles as $role) {
            if (!is_array($role->_permission_ids)) {
                $role->_permission_ids = explode(',', $role->_permission_ids);
            }
            $permissions_ids = array_merge($permissions_ids, $role->_permission_ids);
        }
        $perms = $this->permissionFetchById($permissions_ids);
        foreach ($perms as $perm) {
            foreach ($roles as $role) {
                if (in_array($perm->permission_id, $role->_permission_ids)) {
                    $role->addPermission($perm);
                    continue;
                }
            }
        }
        return true;
    }
483506
public static function findByRole(string $role): array
    {
        return static::find()->where(['id' => \Yii::$app->authManager->getUserIdsByRole($role)])->all();
    }
1084309
public function getRoles() {

		$roles = [];

		foreach($this -> permissions as $role => $permissions) {
			$roles[$role] = $this -> getRole($role);
		}

		return $roles;
	}
582395
public function getSubRoles(Role $role) {
		
		$parentName = $role->getRoleName();
		$subRoles = [];
		
		if(array_key_exists($role->getRoleName(), $this->mappedRoleNames)) {
			
			foreach($this->mappedRoleNames[$parentName] as $subRoleName) {
				$subRoles[] = new Role($subRoleName);
			}
			
		}
		
		return $subRoles;

	}
966964
public function hasRoles($roles)
    {
        if (! is_null($this->getUser())) {
            return $this->getUser()->hasRoles($roles);
        }

        return false;
    }
150970
public function setRoles(array $roles) {
		
		$this->roles = [];
		
		foreach($roles as $role) {

			if(!$role instanceof Role) {
				throw new \InvalidArgumentException('Role is not a role instance.');
			}
			if(array_key_exists($role->getRoleName(), $this->roles)) {
				throw new \InvalidArgumentException(sprintf("Role '%s' defined twice.", $role->getRoleName()));
			}

			$this->roles[$role->getRoleName()] = $role;

		}

		return $this;
	}
808701
private List<String> getUsersFor(Collection<String> roles){
		List<String> users = new HashList<>();
		for(String role: roles){
			if(roleMembershipRU.containsKey(role))
				users.addAll(roleMembershipRU.get(role));
		}
		return users;
	}
481385
protected function isOne(array $roles)
    {
        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
504812
public function translateToRoleNames($roles)
    {
        if (!is_array($roles)) {
            if ($roles) {
                $roles = explode(",", $roles);
            } else {
                $roles = array();
            }
        }
        foreach ($roles as $key => $role) {
            if (isset($this->_roleTranslations[$role])) {
                $roles[$key] = $this->_roleTranslations[$role];
            }
        }

        return $roles;
    }