Allows roles to inherit from the registries of other roles

@param string[] $roles
422826
public function inherits(string ...$roles)
    {
        foreach ($roles as $role)
        {
            if (!$this->roleRegistry->exists($role)) {
                throw new \Exception(
                    sprintf(
                        "The role: %s doesnt exist",
                        (string)$role
                    )
                );
            }

            $this->roleRegistry->setRegistryValue($this->session["role"], $role);
        }

        $this->initSession();
    }
1320013
public function roles($roles)
    {
        $this->sync(
            Models::role()->getRoleKeys($roles),
            $this->authority->roles()
        );
    }
956915
public function switchRoleContext($roles)
    {
        if (is_string($roles)) {
            $roles = [$roles];
        }
        if (is_array($roles)) {
            $roleBucket = new RoleBucket($this);
            foreach ($roles as $role) {
                $roleBucket->add($role);
            }
        } else {
            $roleBucket = $roles;
        }
        $context = new RoleSetContext($roleBucket);
        $this->registerContext($context);
        $this->currentContext = $context->getId();
        return $context;
    }
966964
public function hasRoles($roles)
    {
        if (! is_null($this->getUser())) {
            return $this->getUser()->hasRoles($roles);
        }

        return false;
    }
276113
public static function getServerListByRoles(array $roles)
    {
        $servers = [];
        foreach ($roles as $roleCode) {
            $rolesForCode = RoleManager::getServersByRole($roleCode);

            foreach ($rolesForCode as $serverCode) {
                if (in_array($serverCode, $servers, true)) {
                    continue;
                }

                $servers[] = $serverCode;
            }
        }

        return $servers;
    }
934541
public function attachRoles($roles)
    {
        if ($roles instanceof Role) {
            $roles = [$roles->getKey()];
        }

        $this->roles()->sync($roles, false);

        unset($this->relations['roles']);

        return $this;
    }
499625
public function hasAnyRole(...$roles) {
		foreach ($roles as $role) {
			if ($this->hasRole($role)) {
				return true;
			}
		}

		return false;
	}
67941
public function authorizeRoles($roles)
    {
        if (is_array($roles)) {
            return $this->hasAnyRole($roles) ||
                abort(401, 'This action is unauthorized.');
        }
        return $this->hasRole($roles) ||
            abort(401, 'This action is unauthorized.');
    }
561694
public function setRole(string $role) {
		$this->user->role = role::get($role);
		R::store($this->user);
	}
406805
public function setRoles(Collection $roles)
    {
        $this->roles->clear();
        foreach ($roles as $role) {
            $this->roles[] = $role;
        }
    }
110786
protected function addRoles($roles)
    {
        if (!is_array($roles) && !($roles instanceof \Traversable)) {
            $roles = array($roles);
        }

        /* @var $role Role */
        foreach ($roles as $role) {
            if ($this->acl->hasRole($role)) {
                continue;
            }

            if ($role->getParent() !== null) {
                $this->addRoles(array($role->getParent()));
                $this->acl->addRole($role, $role->getParent());
            } elseif (!$this->acl->hasRole($role)) {
                $this->acl->addRole($role);
            }
        }
    }
237406
public function hasRoles($roles)
    {
        $roles = is_array($roles) ? $roles : func_get_args();

        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
481385
protected function isOne(array $roles)
    {
        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
65701
public function setParentRoles(array $parentRoles)
    {
        $this->parentRoles = [];
        foreach ($parentRoles as $parentRole) {
            $this->addParentRole($parentRole);
        }
    }
1282436
private static function buildOrganizationRoles(array $roles, OrganizationInterface $org)
    {
        $orgName = $org->getName();

        if ($org instanceof RoleableInterface) {
            $existingRoles = [];

            foreach ($roles as $role) {
                $existingRoles[] = $role;
            }

            foreach ($org->getRoles() as $orgRole) {
                $roleName = RoleUtil::formatName($orgRole);

                if (!\in_array($roleName, $existingRoles, true)) {
                    $roles[] = $roleName.'__'.$orgName;
                    $existingRoles[] = $roleName;
                }
            }
        }

        return $roles;
    }
769082
protected function addRoles(Collection $roles)
    {
        foreach ($roles as $role) {
            $this->roles[] = $role->token;
            $this->addPermissions($role->permissions);
        }
    }
525191
public function getAccessibleRoles(array $roles)
    {
        $accessibleRoles = $roles;
        foreach ($roles as $role) {
            /**
             * @var $role Role
             */
            if (isset($this->map[$role->getRole()])) {
                foreach ($this->map[$role->getRole()] as $r) {
                    $accessibleRoles[] = new Role($r);
                }
            }
        }

        return $accessibleRoles;
    }