增加配置
@param string $name
@param array $config
@return boolean
518927
public static function addConfig($name, array $config)
    {
        $nameSplit = explode('.', $name);

        $first = array_shift($nameSplit);
        if(!isset(static::$configs[$first]))
        {
            static::$configs[$first] = new ArrayData([]);
        }

        if(isset($nameSplit[0]))
        {
            $configName = implode('.', $nameSplit);
            static::$configs[$first]->set($configName, $config);
            if(false !== ($configs = static::$configs[$first]->get($configName . '.configs')))
            {
                static::load($name, $configs);
            }
        }
        else
        {
            static::$configs[$first]->set($config);
            if(static::$configs[$first]->exists('configs'))
            {
                static::load($name, static::$configs[$first]->get('configs', []));
            }
        }

        return true;
    }
1041388
public function prependExtensionConfig($name, array $config)
    {
        if (!isset($this->extensionConfigs[$name])) {
            $this->extensionConfigs[$name] = [];
        }

        array_unshift($this->extensionConfigs[$name], $config);
    }
122660
protected function loadConfiguration($name, Config $config)
    {
        $themeConfig = CompiledYamlFile::instance("themes://{$name}/{$name}" . YAML_EXT)->content();
        $config->joinDefaults("themes.{$name}", $themeConfig);
    }
987073
private function addChildNode(string $name, array $config, \XMLWriter $writer): void
    {
        $writer->startElement($name);

        foreach ($config as $nodeName => $nodeData) {
            $nodeName = \is_numeric($nodeName) ? 'num__'.$nodeName : $nodeName;

            if (\is_array($nodeData)) {
                $this->addChildNode($nodeName, $nodeData, $writer);
            } elseif (\is_bool($nodeData)) {
                $writer->writeElement($nodeName, $nodeData === true ? 'true' : 'false');
            } else {
                $writer->writeElement($nodeName, (string)$nodeData);
            }
        }

        $writer->endElement();
    }
883082
public static function createServer($name, $config, $isSubServer = false)
    {
        // 创建服务器对象前置操作
        Event::trigger('IMI.SERVER.CREATE.BEFORE', [
            'name'          => $name,
            'config'        => $config,
            'isSubServer'   => $isSubServer,
        ]);
        // 服务器类名
        $serverClassName = 'Imi\Server\\' . $config['type'] . '\Server';
        // 主服务器实例对象
        $server = App::getBean($serverClassName, $name, $config, $isSubServer);
        static::$servers[$name] = $server;
        // 创建服务器对象后置操作
        Event::trigger('IMI.SERVER.CREATE.AFTER', [
            'name'          => $name,
            'config'        => $config,
            'isSubServer'   => $isSubServer,
        ]);
    }
640078
public static function registerConfig($name, array $config) {
		if( empty($config['path']) ) {
			throw new \Exception('Missing a valid "path" in configuration of route "'.$name.'"');
		}
		
// 		$parameters = array();
// 		if( isset($config['parameters']) && is_array($config['parameters']) ) {
// 			foreach( $config['parameters'] as $paramName => $paramConfig ) {
// 				$parameters[] = CLIArgument::make($paramName, $paramConfig);
// 			}
// 		}
		$options = $config;
		unset($options['path'], $options['controller'], $options['parameters']);
		static::register($name, $config['path'], $config['controller'], array(), $options);
	}
1145363
public static function set($name, array $config)
    {
        // 还是没有，那么抛出异常
        if ( ! $config)
        {
            throw new ComponentNotFoundException('The requested component [:component] missing config.', [
                ':component' => $name,
            ]);
        }

        $class = Arr::get($config, 'class');
        if ( ! $class || ! class_exists($class))
        {
            throw new ComponentClassNotFoundException('The requested component class [:class] not found.', [
                ':class' => $class,
            ]);
        }

        /** @var Component $instance */
        $instance = new $class(Arr::get($config, 'params', []));
        foreach (Arr::get($config, 'call', []) as $method => $args)
        {
            call_user_func_array([$instance, $method], $args);
        }

        self::$components[$name] = $instance;
    }
68893
public static function forge($name = 'default', array $config = array())
	{
		if ($exists = static::instance($name))
		{
			\Error::notice('Fieldset with this name exists already, cannot be overwritten.');
			return $exists;
		}

		static::$_instances[$name] = new static($name, $config);

		if ($name == 'default')
		{
			static::$_instance = static::$_instances[$name];
		}

		return static::$_instances[$name];
	}
1284167
public function addConfig(array $config)
    {
        foreach ($config as $id => $entry) {
            $args = [];

            if (is_array($entry) && ! empty($entry)) {
                $values = array_values($entry);
                $entry = $values[0];

                if (isset($values[1])) {
                    $args = $values[1];
                }
            }

            $this->container[$id] = new Service($entry, $args);
        }

        return $this;
    }
1364674
public function loadConfiguration(array $config = [])
    {
        if (isset($config['login'])) {
            $this->setLogin($config['login']);
        }
        if (isset($config['password'])) {
            $this->setPassword($config['password']);
        }
        if (isset($config['dsn'])) {
            $this->setDSN($config['dsn']);
        }
        return $this;
    }
1287332
public function connect($config = [], $name = false)
    {
        $this->connection = Connection::instance($config, $name);
        $query            = $this->connection->getConfig('query');

        if (__CLASS__ != trim($query, '\\')) {
            return new $query($this->connection);
        }

        $this->prefix = $this->connection->getConfig('prefix');

        return $this;
    }
1287686
public function mergeExtension($name, array $config)
    {
        $this->addExtension($name, array_merge(
            $this->getExtension($name),
            $config
        ));
    }
519936
public static function instance($name = null, array $config = null)
    {
        if (null === $name)
        {
            $name = Db::$default;
        }

        if ( ! isset(Db::$instances[$name]))
        {
            // 读取配置
            if (null === $config)
            {
                $config = (array) Config::load(self::$configFile)->get($name);
                Base::getLog()->debug(__METHOD__ . ' get default config', [
                    'name' => $name,
                ]);
            }

            // 合并默认配置
            if (isset(self::$defaultConfig[Arr::get($config, 'driver')]))
            {
                $config = Arr::merge(self::$defaultConfig[Arr::get($config, 'driver')], $config);
                Base::getLog()->debug(__METHOD__ . ' merge config', [
                    'name' => $name
                ]);
            }

            $conn = DriverManager::getConnection($config);
            Base::getLog()->debug(__METHOD__ . ' create dbal connection', [
                'name' => $name
            ]);

            // 额外注册字段类型
            if (isset(self::$mappingType[Arr::get($config, 'driver')]))
            {
                $platform = $conn->getDatabasePlatform();
                foreach (self::$mappingType[Arr::get($config, 'driver')] as $dbType => $doctrineType)
                {
                    if ( ! $platform->hasDoctrineTypeMappingFor($dbType))
                    {
                        Base::getLog()->debug(__METHOD__ . ' add dbal mapping type', [
                            'raw'  => $dbType,
                            'dbal' => $doctrineType,
                        ]);
                        $platform->registerDoctrineTypeMapping($dbType, $doctrineType);
                    }
                }
            }

            Db::$instances[$name] = $conn;
            Base::getLog()->debug(__METHOD__ . ' save db instance', [
                'name' => $name
            ]);
        }

        return Db::$instances[$name];
    }
488632
public function getId($name, $config)
    {
        $inputId = str_replace('[]', '', ucfirst($name));

        if (isset($config['id'])) {
            $inputId = $config['id'];
        }

        return $inputId;
    }
1133971
private function configure(array $config = [])
    {
        foreach ($config as $property => $value) {
            if (property_exists($this, $property)) {
                $this->{$property} = $value;
            }
        }
    }
187027
public function init(array $config = [])
    {
        if (!extension_loaded('redis')) {
            return false;
        }

        if (!empty($config['host'])) {
            $config['server'] = $config['host'];
        }

        parent::init($config);

        return $this->_connect();
    }
912731
public function save($name, Config $config)
  {
    $path = $this->_getPath($name);
    
    $data = $config->valueOf();
    file_put_contents(
      $path, serialize($data)
    );
    
    return true;
  }