@param array|string|IConfig $config

@throws InvalidRuntimeConfigException

@return IConfigLoader
508892
public function addConfig($config) {
        if (is_array($config)) {
            // array of paths to config files
            if (array_is_indexed($config)) {
                $this->addPaths($config);
            }
            // array of key value configs
            else {
                $this->addRuntimeConfig($config);
            }
        }
        // path to config file
        else if (is_string($config)) {
            $this->addPath($config);
        }
        // config object
        else if ($config instanceof IConfig) {
            $this->addRuntimeConfig($config);
        }

        return $this;
    }
605371
public function extensionFromConfig(array $config)
    {
        $extension = new Extension();

        $extension->setName(array_get($config, 'name'));
        $extension->setHandle(array_get($config, 'handle'));

        $asset = $this->assetList->getAsset('javascript', array_get($config, 'src'));
        if (!$asset) {
            $handle = array_get($config, 'handle');
            throw new \RuntimeException("Could not build extension \"{$handle}\", invalid extension asset.");
        } else {
            $extension->setExtensionAsset($asset);
        }

        $view = new View(array_get($config, 'view'));
        $extension->setView($view);

        $assets = (array) array_get($config, 'assets');
        foreach ($assets as $handle => $asset_config) {
            $asset_config = (array) $asset_config;

            foreach ($asset_config as $type) {
                if ($asset = $this->assetList->getAsset($type, $handle)) {
                    $extension->addAsset($asset);
                } else {
                    $handle = array_get($config, 'handle');
                    throw new \RuntimeException("Could not build extension \"{$handle}\", invalid asset.");
                }
            }
        }

        return $extension;
    }
184381
protected function getLocalConfigArrays(IConfigSource $config)
    {
        $src = $config->getSource();

        $result = [
            $config->getAlias() => $this->convertToArray($src)
        ];

        array_walk_recursive(
            $src,
            function ($value) use (&$result) {
                if ($value instanceof IConfigSource) {
                    $result[$value->getAlias()] = $this->convertToArray($value->getSource());
                }
            }
        );

        return $result;
    }
1117126
protected function getConfig($config = []): ConfigInterface
    {
        $defaults = ConfigFactory::create(dirname(__DIR__, 2) . '/config/defaults.php', $config);
        $config   = $config
            ? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy()))
            : $defaults;

        return $config->getSubConfig('BrightNucleus\View');
    }
85121
public static function init(array $config)
    {
        if (empty($config['storage']) || ($config['storage'] != self::FILE && $config['storage'] != self::POP3)) {
            throw new \InvalidArgumentException('need at least type in params');
        }

        $className = __NAMESPACE__.'\\'.$config['storage'];

        return new  $className($config);
    }
1043129
public static function getInstance(Config $config = null) {

		if(is_null(self::$instance)) {
			if(is_null($config)) {
				throw new ApplicationException('No configuration object provided. Cannot instantiate application.');
			}
			self::$instance = new Application($config);
		}

		return self::$instance;

	}
888784
public function create($adapterType, array $config)
    {
        if (!array_key_exists($adapterType, $this->adapters)) {
            throw new \InvalidArgumentException(
                sprintf('Cache Adapter\'s key %s does not exist', $adapterType)
            );
        }

        /**
         * @fixme : Active this part & clean cache config
         */
        if (!isset($config[$adapterType])) {
            throw new InvalidConfigurationException(
                sprintf('Config is not set for adapter %s', $adapterType)
            );
        }

        return new $this->adapters[$adapterType]($config[$adapterType]);
    }
1247908
public static function config($config)
    {
        foreach ($config as $key => $value) {
            self::$config[$key] = $value;
        }

        //Re-set the admin url if shop url is changed
        if(isset($config['ShopUrl'])) {
            self::setAdminUrl();
        }

        //If want to keep more wait time than .5 seconds for each call
        if (isset($config['AllowedTimePerCall'])) {
            static::$timeAllowedForEachApiCall = $config['AllowedTimePerCall'];
        }

        return new ShopifySDK;
    }
881412
public function helper($name, array $config = []) {
		if (isset($this->_helpers[$name])) {
			return $this->_helpers[$name];
		}
		try {
			$config += ['context' => $this];
			return $this->_helpers[$name] = Libraries::instance('helper', ucfirst($name), $config);
		} catch (ClassNotFoundException $e) {
			if (ob_get_length()) {
				ob_end_clean();
			}
			throw new RuntimeException("Helper `{$name}` not found.");
		}
	}
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;
    }
282566
protected function createFileSystem(array $config): FileSystem
    {
        if (! isset($config['adapter'])) {
            throw new RuntimeException('Filesystem adapter is undefined');
        }

        $adapters = [
            'local' => 'Local',
            'aliyun' => 'Aliyun',
        ];

        if (! isset($adapters[$config['adapter']])) {
            throw new RuntimeException(
                sprintf('Filesystem adapter "%s" is invalid', $config['adapter'])
            );
        }

        $adapter = $adapters[$config['adapter']];

        unset($adapters);

        return new FileSystem(
            $this->createAdapter($adapter, $config)
        );
    }
228679
protected function loadDoctrine(array $config, ContainerBuilder $container)
    {
        foreach ($config['doctrine'] as $name => $cache) {
            if (empty($cache['entity_managers']) && empty($cache['document_managers'])) {
                throw new InvalidConfigurationException(sprintf('Enabling the doctrine %s section requires it to reference either an entity manager or document manager', $name));
            }

            if ('second_level_cache' === $name) {
                $name = 'second_level_cache.region_cache_driver';
            }
            $definitionFunction = null;
            switch ($config['clients'][$cache['client']]['type']) {
                case 'predis':
                    $definitionFunction = function ($client, $cache) use ($container) {
                        $def = new Definition($container->getParameter('snc_redis.doctrine_cache_predis.class'));
                        $def->addArgument($client);
                        if ($cache['namespace']) {
                            $def->addMethodCall('setNamespace', array($cache['namespace']));
                        }

                        return $def;
                    };
                    break;
                case 'phpredis':
                    $definitionFunction = function ($client, $cache) use ($container) {
                        $def = new Definition($container->getParameter('snc_redis.doctrine_cache_phpredis.class'));
                        $def->addMethodCall('setRedis', array($client));
                        if ($cache['namespace']) {
                            $def->addMethodCall('setNamespace', array($cache['namespace']));
                        }

                        return $def;
                    };
                    break;
            }

            $client = new Reference(sprintf('snc_redis.%s', $cache['client']));
            foreach ($cache['entity_managers'] as $em) {
                $def = call_user_func_array($definitionFunction, array($client, $cache));
                $container->setDefinition(sprintf('doctrine.orm.%s_%s', $em, $name), $def);
            }
            foreach ($cache['document_managers'] as $dm) {
                $def = call_user_func_array($definitionFunction, array($client, $cache));
                $container->setDefinition(sprintf('doctrine_mongodb.odm.%s_%s', $dm, $name), $def);
            }
        }
    }
1311902
protected function parseString(IConfig $config, $string) {
        if ($this->isReference($string)) {
            $value = $config->get($this->parseReferencePath($string));
        } else {
            $value = preg_replace_callback($this->getInterpolationRegexPattern(), function($matches) use ($config) {
                $value = $config->get($matches[1]);

                if ( ! is_scalar($value)) {
                    return $matches[0];
                }

                return $value;
            }, $string);
        }

        return $value;
    }
937724
public function replace(array $config) : ConfigInterface
    {
        foreach ($config as $key => $configuration) {
            $this->set($key, $configuration);
        }

        return $this;
    }
425120
protected function applyHooks(Config $config)
    {
        $hooks = $config->get('hooks', null);

        $config->set('hooks', []);

        if (!isset($hooks) || !is_array($hooks) || !count($hooks)) {
            return $this;
        }

        foreach ($hooks as $type => $hookDefinitions) {
            if (!is_array($hookDefinitions)) {
                $hookDefinitions = [];
            }
            if (count($hookDefinitions)) {
                $hooks[$type] = [];
            }
            foreach ($hookDefinitions as $hook) {
                if (!($hook instanceof HookInterface)) {
                    if (is_string($hook) && '@' === $hook{0}) {
                        $hook = new CommandHook($hook);
                    } else {
                        throw new \RuntimeException(sprintf("Unsupported hook definition format: %s", json_encode($hook)), 412);
                    }
                }
                $hooks[$type][] = $hook;
            }
        }

        $config->set('hooks', $hooks);

        return $this;
    }
745903
public function setConfig($config)
    {
        if (is_string($config)) {
            // Treat the parameter as a filepath
            $this->config = $this->createConfig($config);
        } elseif (is_array($config)) {
            $this->config = $this->createConfig($config);
        } elseif ($config instanceof ConfigInterface) {
            $this->config = $config;
        } else {
            throw new InvalidArgumentException(sprintf(
                'Configset must be an associative array, a file path, or an instance of %s',
                ConfigInterface::class
            ));
        }

        return $this;
    }
533302
public function setContextConfig(array $config)
    {
        if ($this->type == InternalBaseBlock::INJECTOR_VAR) {
            return $this->context->addVar($config, $this->append);
        }
         
        if ($this->type == InternalBaseBlock::INJECTOR_CFG) {
            return $this->context->addCfg($config, $this->append);
        }
        
        throw new InvalidConfigException("The type '{$this->type}' is not supported.");
    }