@param string $name
@param array  $config

@return self
167158
public static function init($name = "", $config = [])
    {
        if (empty($name)) {
            $name = "redis.default";
        }
        if (isset(self::$instance[$name])) {
            return self::$instance[$name];
        }
        $hosts = isset($config['hosts']) ? $config['hosts'] : [];

        $is_cluster = !empty($hosts);

        $default_config = $is_cluster ? self::$defaultConfig["cluster"] : self::$defaultConfig["single"];

        $config = array_merge($default_config, $config);

        self::$instance[$name] = self::instance($config);

        return self::$instance[$name];
    }
92391
public function applyConfig(array $config = []) {
        $parent = $this;
        $defaults = isset($this->_config) ? $this->_config : [];

        // Inherit config from parents
        while ($parent = get_parent_class($parent)) {
            $props = get_class_vars($parent);

            if (isset($props['_config'])) {
                $defaults = Hash::merge($props['_config'], $defaults);
            }
        }

        $this->__config = new ConfigAugment($config, $defaults);

        return $this;
    }
363248
public function createFromArray($config)
    {
        foreach ($config as $property => $value) {
            $this->{$property} = $value;
        }

        return $this;
    }
1119523
public function setConfig($name, array $config)
    {
        if (isset($this->configs[$name])) {
            throw new \InvalidArgumentException(sprintf(
                '%s config "%s" already exists.',
                $this->serviceType,
                $name
            ));
        }

        $this->configs[$name] = $config;
    }
95191
public function appendExtension($name, array $config = [])
    {
        $merged = array_merge_recursive(
            $this->getExtension($name),
            $config
        );

        $this->addExtension($name, $merged);
    }
985147
protected function createForConnection($name, array $config = [])
    {
        if (isset($this->customCreators[$name])) {
            return $this->callCustom($name, compact('config'));
        }
    }
506053
public static function run($name, array $config = array())
    {
        $generator = self::create($name, $config);

        if (!$generator->validate()) {
            $generator->renderErrors();
        }

        return $generator->generate();
    }
68207
protected function configure(array $config = [])
    {
        foreach ($config as $key => $value) {
            $method = 'set' . $key;
            if (method_exists($this, $method)) {
                $this->$method($value);
            }
        }
    }
921424
public static function make(array $config = [], $name = '')
    {
        if (!\is_array($config)) {
            throw new \InvalidArgumentException('Logger config is must be an array and not allow empty.');
        }

        $name = $name ?: ($config['name'] ?? '');

        if (!$name) {
            throw new \InvalidArgumentException('Logger name is required.');
        }

        if (!isset(self::$loggers[$name])) {
            self::$loggers[$name] = new static($config, $name);
        }

        // register shutdown function
        if (!self::$shutdownRegistered) {
            register_shutdown_function(function () {
                // make regular flush before other shutdown functions, which allows session data collection and so on
                self::flushAll();

                // make sure log entries written by shutdown functions are also flushed
                // ensure "flush()" is called last when there are multiple shutdown functions
                register_shutdown_function([self::class, 'flushAll'], true);
            });

            self::$shutdownRegistered = true;
        }

        return self::$loggers[$name];
    }
1153907
public function getCommand($name, Config $config)
    {
        if (!$config->hasItem('commands', $name)) {
            if (!$config->hasItem('commands', '_'.$name)) {
                $config->checkItem('commands', $name);
            }
            $name = '_'.$name;
        }

        return $config->getItem('commands', $name);
    }
854781
public function mergeConfig(array $config): self
    {
        $this->config = array_merge($this->config, $config);

        return $this;
    }
1005532
public static function makeProxy(string $name, array $config)
    {
        $mode = $config['mode'];
        if ($mode == Macro::CLUSTER) {
            return new RedisProxyCluster($name, $config);
        } elseif ($mode == Macro::MASTER_SLAVE) {
            return new RedisProxyMasterSlave($name, $config);
        } else {
            return false;
        }
    }
1133971
private function configure(array $config = [])
    {
        foreach ($config as $property => $value) {
            if (property_exists($this, $property)) {
                $this->{$property} = $value;
            }
        }
    }
449673
public static function getInstance($config = array())
    {
        static $instance;

        if ($instance === null) {
            if (!$config instanceof AnConfig) {
                $config = new AnConfig($config);
            }

            $instance = new self($config);
        }

        return $instance;
    }
1011146
public function setConfig(array $config = [])
    {
        $config = $config + $this->config;

        foreach ($this->defaults as $key => $value) {
            if (!array_key_exists($key, $config)) {
                $config[$key] = $value;
            }
        }

        $this->config = $config;

        return $this;
    }
943469
public function setConfig($config)
    {
        if (is_array($config)) {
            $this->config = $this->createConfig($config);
        } elseif ($config instanceof ConfigInterface) {
            $this->config = $config;
        } else {
            throw new InvalidArgumentException(
                'Configuration must be an array or a ConfigInterface object.'
            );
        }
        return $this;
    }
923280
public function addCommand($name, $config = array())
    {
        $command = parent::addCommand($name, $config);

        $controller = $this->getController();

        if($controller->isEditable() && KStringInflector::isSingular($controller->getView()->getName())) {
            $command->disabled = true;
        }

        return $this;
    }