Modify `Router` configuration settings and dependencies.

@param array $config Optional array to override configuration. Acceptable keys are
`'classes'` and `'unicode'`.
@return array Returns the current configuration settings.
546247
public static function config($config = []) {
		if (!$config) {
			return ['classes' => static::$_classes, 'unicode' => static::$_unicode];
		}
		if (isset($config['classes'])) {
			static::$_classes = $config['classes'] + static::$_classes;
		}
		if (isset($config['unicode'])) {
			static::$_unicode = $config['unicode'];
		}
	}
401729
protected function getRequestConfig(array $config) : array
    {
        if (!empty($this->defaultRequestOptions)) {
            $config = array_replace_recursive($this->defaultRequestOptions, $config);
        }

        return $config;
    }
940451
private function configureOptions(array $config): array
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'device' => [],
        ]);

        $resolver->setRequired(['message']);
        $resolver->setAllowedTypes('message', 'array');
        $resolver->setAllowedTypes('device', 'array');

        $options = $resolver->resolve($config);

        $deviceResolver = new OptionsResolver();
        $options['device'] = $deviceResolver->resolve($options['device']);

        $messageResolver = new OptionsResolver();
        $messageResolver->setRequired(['defaultTitle', 'defaultMediaUrl', 'defaultActionUrl']);

        $messageResolver->setAllowedTypes('defaultTitle', 'string');
        $messageResolver->setAllowedTypes('defaultMediaUrl', 'string');
        $messageResolver->setAllowedTypes('defaultActionUrl', 'string');

        $options['message'] = $messageResolver->resolve($options['message']);

        return $options;
    }
797919
public function setConfig(array $config)
    {
        // Filter out unknown config keys, and use to override defaults
        $config = array_merge(
            $this->config,
            array_intersect_key($config, $this->config)
        );

        // Normalize allowMethods
        if (is_string($config['allowMethods'])) {
            $config['allowMethods'] = [$config['allowMethods']];
        }

        // Normalize allowHeaders
        if (is_string($config['allowHeaders'])) {
            $config['allowHeaders'] = [$config['allowHeaders']];
        }

        // Normalize allowOrigins
        if (is_string($config['allowOrigins'])) {
            $config['allowOrigins'] = [$config['allowOrigins']];
        }

        // Normalize allowCredentials
        $config['allowCredentials'] = (bool)$config['allowCredentials'];

        // Normalize maxAge
        $config['maxAge'] = (int)$config['maxAge'];

        /** @todo Check for use of wildcard in allowOrigins when allowCredentials equals true */

        // Set config as object attribute
        $this->config = $config;

        return $this;
    }
1306412
protected function getDsn(array $config)
    {
        return $this->configHasSocket($config) ? $this->getSocketDsn($config) : $this->getHostDsn($config);
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
149428
protected function setBasicOptions(array $config)
    {
        if (!isset($config['timeout'])) {
            $config['timeout'] = static::DEFAULT_REQUEST_TIMEOUT;
        }

        if (isset($config['base_uri']) && strpos($config['base_uri'], 'http') === false) {
            $config['base_uri'] = 'https://' . $config['base_uri'];
            return $config;
        }
        return $config;
    }
1245811
public function config(array $config)
    {
        parent::config($config);

        if (array_key_exists('http_method', $config)) {
            $this->defaults->setHttpMethod($config['http_method']);
        }

        return $this;
    }
1072846
public function configure(array $config = [])
    {
        // Check if config has defined a tempDir
        if (isset($config['tempDir']) && is_dir($config['tempDir'])) {
            $this->tempDir = $config['tempDir'];
        }

        return $this;
    }
135950
protected function flattenConfig(array $config)
	{
		foreach ($config as $k => $v)
		{
			if (is_array($v) && count($v) === 1)
			{
				$config[$k] = end($v);
			}
		}

		return $config;
	}
1097158
public function getOptions(array $config)
    {
        $options = array_get($config, 'options', array());

        return array_diff_key($this->options, $options) + $options;
    }
136957
public function loadFromArray(array $config)
    {
        if (isset($config['domains'])) {
            $this->loadDomainConfiguration($config);
        }

        if (isset($config['general'])) {
            $general = $config['general'];
            $generalConfig = $this->getParsedConfig(
                $general,
                $this->config,
                $this->yamlConfigMap,
                []
            );
            $this->setCache(CacheFactory::get($generalConfig['cacheType'], $generalConfig['cacheOptions']));
            unset($generalConfig['cacheType']);
            unset($generalConfig['cacheOptions']);
            $this->setParsedConfig($generalConfig);
        }

        return $this;
    }
159701
public function init(array $config = []) : self
    {
        $host = $config[RouterConfig::ROUTER_CONNECTION_HOST] ?? RouterConfig::AMQP_RABBIT_DEFAULT_HOST;
        $port = $config[RouterConfig::ROUTER_CONNECTION_PORT] ?? RouterConfig::AMQP_RABBIT_DEFAULT_PORT;
        $login = $config[RouterConfig::ROUTER_CONNECTION_LOGIN] ?? RouterConfig::AMQP_RABBIT_DEFAULT_LOGIN;
        $password = $config[RouterConfig::ROUTER_CONNECTION_PASSWORD] ?? RouterConfig::AMQP_RABBIT_DEFAULT_PASSWORD;
        $vhost = $config[RouterConfig::ROUTER_CONNECTION_VHOST] ??  RouterConfig::AMQP_RABBIT_DEFAULT_VHOST;
        
        $defaultServer = new RouterServer(
            $host, 
            $port,
            $login, 
            $password,
            $vhost,
            RouterConfig::SERVER_TAG_DEFAULT
        );
        
        $this->registry->registerServer($defaultServer);
        
        return $this;
    }
240633
public function connect(array $config)
    {
        $dsn = $this->getDsn($config);

        $options = $this->getOptions($config);

        $connection = $this->createConnection($dsn, $config, $options);

        //
        $collation = $config['collation'];

        $charset = $config['charset'];

        $names = "set names '$charset'".
            (! is_null($collation) ? " collate '$collation'" : '');

        $connection->prepare($names)->execute();

        if (isset($config['strict']) && $config['strict']) {
            $connection->prepare("set session sql_mode='STRICT_ALL_TABLES'")->execute();
        }

        return $connection;
    }
1346023
protected function loadInstalledComponentsConfig(array $config = []) : array
    {
        $env    = $this->env === self::WEB ? 'web' : 'console';
        $config = FileHelper::loadExtensionsFiles('config/main.php',   $config);
        $config = FileHelper::loadExtensionsFiles("config/{$env}.php", $config);
        return $config;
    }
1018426
protected function getReadConfig(array $config)
    {
        $readConfig = $this->getReadWriteConfig($config, 'read');

        return $this->mergeReadWriteConfig($config, $readConfig);
    }
1328135
public static function config($config = null) {
		$defaults = ['scope' => null];

		if (is_array($config)) {
			foreach ($config as $i => $item) {
				$config[$i] += $defaults;
			}
		}
		return parent::config($config);
	}