Add a role to service configuration

@param string $name
323916
public function addRole($name)
    {
        $namespaceUri = $this->dom->lookupNamespaceUri($this->dom->namespaceURI);

        $roleNode = $this->dom->createElementNS($namespaceUri, 'Role');
        $roleNode->setAttribute('name', $name);

        $instancesNode = $this->dom->createElementNS($namespaceUri, 'Instances');
        $instancesNode->setAttribute('count', '2');

        $configurationSettings = $this->dom->createElementNS($namespaceUri, 'ConfigurationSettings');

        $roleNode->appendChild($instancesNode);
        $roleNode->appendChild($configurationSettings);

        $this->dom->documentElement->appendChild($roleNode);

        $this->save();
    }
848148
public function hasRole($name)
    {
        if ($this->RoleID) {
            $role = new Role($this->RoleID);
            if ($role->RoleName == $name) {
                return true;
            }
        }

        foreach ($this->Roles as $role) {
            if ($role->RoleName == $name) {
                return true;
            }
        }
        return false;
    }
1060804
public function setRole($name, $description = null)
    {
        $role = $this->getRole($name) ?: $this->createRole($name);
        if ($description) {
            $role->description = $description;
        }
        $this->add($role);

        return $role;
    }
1097122
protected function setConfigurationFile(string $name, array $headers)
    {
        $this->info('Set plugin configuration...');

        $prefix = trim($headers['plugin_prefix'], '\/_-');
        $from = $this->path($name.'/config/prefix_plugin.php');
        $to = $this->path($name.'/config/'.$prefix.'_plugin.php');

        $this->files->move($from, $to);
        $this->replaceFileContent($to, $headers);
    }
1278441
private function resolveConfig($name)
    {
        $config = $this->configs[$name];

        if (isset($config['extends'])) {
            $extended = $this->getConfig($config['extends']);

            if (isset($config[$this->serviceType]) && ($extended[$this->serviceType] != $config[$this->serviceType])) {
                throw new \InvalidArgumentException(sprintf(
                    '%s configuration for service "%s" cannot extend configuration for different service "%s"',
                    $this->serviceType,
                    $config[$this->serviceType],
                    $extended[$this->serviceType]
                ));
            }

            unset($config['extends']);
            $config = array_merge(
                $extended->getArrayCopy(),
                $config
            );
        }

        if (!isset($config[$this->serviceType])) {
            throw new \InvalidArgumentException(sprintf(
                '%s configuration must EITHER indicate its target %s service with the "%s" key or extend an existing configuration with the "extends" key.',
                $this->serviceType,
                $this->serviceType,
                $this->serviceType
            ));
        }

        /** @var RegistrableInterface $service */
        $service = $this->getService($config[$this->serviceType]);

        $options = new OptionsResolver();
        $options->setRequired([$this->serviceType]);
        $service->configure($options);
        $config = $options->resolve($config);

        $this->resolvedConfigs[$name] = new Config($name, $config);
    }
933875
public function assignRole ($name)
		{
			$auth = Yii::$app->getAuthManager();
			$role = $auth->getRole($name);
			if ($role)
				$auth->assign($role, $this->id);
		}
437233
public function set(string $name, callable $callback): void
    {
        $this->services[$name] = function ($c) use ($callback) {
            static $object;

            if ($object === null) {
                $object = $callback($c);
            }

            return $object;
        };
    }
133677
public function loadConfig($name)
    {
        // only if config not yet exists
        if (!$this->configExists($name))
            $this->config[$name] = $this->getConfigObjectFromDatabase($name);
    }
1099536
protected function registerService($name, $service)
    {
        $name = strtolower($name);

        if (!isset($this->services->$name)) {
            $this->services->$name = $service;
            return true;
        }
        return false;
    }
971907
public function addRole($roleName)
    {
        if (true === is_string($roleName) && false === in_array($roleName, $this->roles)) {
            $this->roles[] = $roleName;
        }
        return $this;
    }
868465
public function addConfigurationSetting($name, $value)
    {
        $this->checkConnectionUp("Cannot set configuration once a connection is made with the server.")
            ->configurator->set($name, $value);

        return $this;
    }
774250
public function createRole($name) {
		$result = $this->repository->createRole($name);
		$this->domain->const->generateRoles();
		return $result;
	}
218032
public function addRole($idOrName)
    {
        $ids = is_array($idOrName) ? $idOrName : func_get_args();

        foreach ($ids as $search) {
            $role = Role::search($idOrName)->firstOrFail();

            $this->roles()->attach($role->id);
        }
    }
685038
public function setService(string $name, $service)
    {
        if (isset($this->services[$name]) && ! $this->allowOverride) {
            throw ContainerModificationsNotAllowedException::fromExistingService($name);
        }
        $this->services[$name] = $service;
    }
887937
public function hasRole($name)
    {
        if (is_string($name)) {
            return collect($this->roles)->contains($name);
        }

        return (bool) collect($this->roles)->intersect($name->lists('name'))->count();
    }
987862
public function configure($name)
    {
        if (isset($this->loadedConfigurations[$name])) {
            return;
        }
        //标记为已加载
        $this->loadedConfigurations[$name] = true;
        $path = $this->getConfigurationPath($name);
        if ($path) {
            $this->make('config')->set($name, require $path);
        }
    }
366584
public function setService($name, $service)
    {
        $this->services[$name] = $service;
        $this->serviceConfiguration[$name]['persistent'] = true;
        return $this;
    }