Import encountered files in the configuration

@param Config $baseConfig
@throws AdapterNotFoundException
@throws ConstantDirNotFoundException
@throws ExtensionNotFoundException
554707
protected function importResource(BaseConfig $baseConfig)
    {
        foreach ($baseConfig as $key => $value) {
            if ($value instanceof BaseConfig) {
                $this->importResource($value);
            } elseif (is_string($value)) {
                if ($key === self::RESOURCES_KEY) {
                    $resources = $this->clear(
                        $baseConfig,
                        $this->create($value)
                    );
                    $baseConfig->merge($resources);
                    $baseConfig->offsetUnset($key);

                } elseif (substr_count($value, self::RESOURCES_VALUE)) {
                    $baseConfig[$key] = $this->create(
                        substr($value, strlen(self::RESOURCES_VALUE))
                    );

                } elseif ($key === self::MODULE_KEY) {
                    $resources = $this->clear(
                        $baseConfig,
                        $this->moduleConfigCreate($value)
                    );

                    $baseConfig->merge($resources);
                    $baseConfig->offsetUnset($key);

                } elseif (substr_count($value, self::MODULE_VALUE)) {
                    $baseConfig[$key] =
                        $this->moduleConfigCreate(
                            substr(
                                $value,
                                strlen(self::MODULE_VALUE)
                            )
                        );

                }

                if (substr_count($value, self::ENVIRONMENT)) {
                    $baseConfig[$key] = str_replace(
                        self::ENVIRONMENT,
                        $this->environment,
                        $value
                    );
                }
            }
        }
    }
1105284
protected function loadExtensions(Config $config)
    {
        $uses = $config->get('uses', []);

        foreach ($uses as $use => $useSettings) {
            $this->loadExtension($use, $useSettings, $config);
        }

        return $this;
    }
294508
protected function _applyConfig($config)
    {
        if (is_string($config)) {
            $name = $config;
            $config = static::getConfig($name);
            if (empty($config)) {
                throw new InvalidArgumentException(sprintf('Unknown email configuration "%s".', $name));
            }
            unset($name);
        }

        $this->_profile = array_merge($this->_profile, $config);

        $simpleMethods = [
            'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath',
            'cc', 'bcc', 'messageId', 'domain', 'subject', 'attachments',
            'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset'
        ];
        foreach ($simpleMethods as $method) {
            if (isset($config[$method])) {
                $this->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (empty($this->headerCharset)) {
            $this->headerCharset = $this->charset;
        }
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        $viewBuilderMethods = [
            'template', 'layout', 'theme'
        ];
        foreach ($viewBuilderMethods as $method) {
            if (array_key_exists($method, $config)) {
                $this->viewBuilder()->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (array_key_exists('helpers', $config)) {
            $this->viewBuilder()->setHelpers($config['helpers'], false);
        }
        if (array_key_exists('viewRender', $config)) {
            $this->viewBuilder()->setClassName($config['viewRender']);
        }
        if (array_key_exists('viewVars', $config)) {
            $this->set($config['viewVars']);
        }
    }
455795
public function load(array $config, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $config);

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('container.yml');
        $loader->load('own.yml');
        $loader->load('system.yml');
        $loader->load('party.yml');
        $loader->load('store.yml');
        $loader->load('credential.yml');
        $loader->load('service.yml');
        $loader->load('provider.yml');
        $loader->load('profile.yml');

        $this->configureOwn($container, $config);
        $this->configureSystem($container, $config);
        $this->configureParty($container, $config);
        $this->configureStore($container, $config);
        $this->configureCredential($container, $config);
        $this->configureService($container, $config);
    }
786097
public function createMapping(Configuration $config)
    {
        $this->createBaseStructure($config);
        $this->createExchanges($config);
        $this->createQueues($config);
        $this->setPermissions($config);
    }
351202
private function processFinders(array $config)
    {
        $finders = array();
        $filter = $this->getBlacklistFilter();

        foreach ($config as $methods) {
            $finder = Finder::create()
                        ->files()
                        ->filter($filter)
                        ->ignoreVCS(true);

            if (isset($methods->in)) {
                $base = $this->getBasePath();
                $methods->in = (array) $methods->in;

                array_walk(
                    $methods->in,
                    function (&$directory) use ($base) {
                        $directory = Path::canonical(
                            $base . DIRECTORY_SEPARATOR . $directory
                        );
                    }
                );
            }

            foreach ($methods as $method => $arguments) {
                if (false === method_exists($finder, $method)) {
                    throw new InvalidArgumentException(
                        sprintf(
                            'The method "Finder::%s" does not exist.',
                            $method
                        )
                    );
                }

                $arguments = (array) $arguments;

                foreach ($arguments as $argument) {
                    $finder->$method($argument);
                }
            }

            $finders[] = $finder;
        }

        return $finders;
    }
787160
private function configureDatabase(array $config) {
        if (!isset($config['database']) || !isset($config['database']['adapter'])) {
            throw new InvalidArgumentException('Missing database adapter configuration for the image variations event listener', 500);
        }

        $config = $config['database'];

        if (is_callable($config['adapter'])) {
            $databaseAdapter = $config['adapter']();
        } else if (is_string($config['adapter'])) {
            $databaseAdapter = new $config['adapter'](isset($config['params']) ? $config['params'] : null);
        } else {
            $databaseAdapter = $config['adapter'];
        }

        if (!($databaseAdapter instanceof DatabaseInterface)) {
            throw new InvalidArgumentException('Invalid database adapter for the image variations event listener', 500);
        }

        $this->database = $databaseAdapter;
    }
1287349
public function setConfiguration(Configuration $config)
    {
        if ($config === null) {
            throw new Exception\InvalidArgumentException('$config cannot be null');
        }


        if ($this->config !== null) {
            $this->config->unregisterConfigChangeListener($this->getConfigChangeListener());
        }

        $this->config = $config;
        $this->setOptions($config->getZendLdapConfiguration());
        $this->config->registerConfigChangeListener($this->getConfigChangeListener());
    }
942527
protected function setUpGeneralConfigurations(Configuration $config)
    {
        $this->setupAnnotationMetadata();
        $config->setMetadataDriverImpl($this->getMetadataMappingDriver());

        $config->setProxyDir($this->getProxiesPath());
        $config->setProxyNamespace($this->getProxiesNamespace());
        $config->setAutoGenerateProxyClasses($this->getProxiesAutoGeneration());

        $config->setMetadataCacheImpl($this->getMetadataCacheDriver());
    }
152138
public static function getEmptyInstance(array $baseConfig = null) :Config
    {
        if (!is_null($baseConfig)) {
            $config = new Config($baseConfig);
        } else {
            $config = new Config();
        }
        return $config;
    }
992429
public function setConfig($config)
    {
        if(is_string($config)){
            if (file_exists($config)) {
                $config = \Zend\Config\Factory::fromFile($config);
            } else {
                throw new \InvalidArgumentException(
                    sprintf('Unable to read configurations from file %s',$config));
            }
        }
    
        if(!is_array($config) && !($config instanceof \Traversable)){
            throw new \InvalidArgumentException(
                    sprintf('Config must be an array, Traversable object or filename; %s received',
                            is_object($config) ? get_class($config) : gettype($config)));
        }
    
        $this->setOptions($config);
    }
897112
protected function setUpGeneralConfigurations(Configuration $config)
    {
        $this->setupAnnotationMetadata();
        $config->setMetadataDriverImpl($this->getMetadataMappingDriver());

        $config->setProxyDir($this->getProxiesPath());
        $config->setProxyNamespace($this->getProxiesNamespace());
        $config->setAutoGenerateProxyClasses($this->getProxiesAutoGeneration());

        if ($this->getRepositoryFactory() !== null) {
            $config->setRepositoryFactory($this->getRepositoryFactory());
        }

        if ($this->getDefaultRepositoryClass() !== null) {
            $config->setDefaultRepositoryClassName($this->getDefaultRepositoryClass());
        }

        $config->setMetadataCacheImpl($this->getMetadataCacheDriver());
    }
1142485
public function setConfig(array $config)
    {
        if (!isset($config['thumbnailer'])) {
            $this->_thumbnailer = new Thumbnailer();
        } elseif (class_exists($config['thumbnailer'])) {
            $this->_thumbnailer = new $config['thumbnailer'];
        } else {
            throw new ConfigurationException('Class ' . $config['thumbnailer'] . ' does not exist.');
        }

        if (!($this->_thumbnailer instanceof ThumbnailerInterface)) {
            throw new ConfigurationException('Class ' . get_class($this->_thumbnailer) . ' must implement the interface \ysaroka\autothumb\ThumbnailerInterface.');
        }

        if (!isset($config['document_root'])) {
            throw new ConfigurationException('"document_root" key is required.');
        }

        if (!is_dir(realpath($config['document_root']))) {
            throw new ConfigurationException('"document_root": directory "' . $config['document_root'] . '" does not exist.');
        }

        if (!isset($config['types']) || count($config['types']) == 0) {
            throw new ConfigurationException('"types" key is required and should not be empty.');
        }

        foreach ($config['types'] as $type => $params) {
            if (!preg_match('#^[\w\d]+$#', $type)) {
                throw new ConfigurationException('"type": type name "' . $type . '" must contain only words and numbers.');
            }

            if (!isset($params['width'])) {
                $config['types'][$type]['width'] = 100;
            }

            if (!isset($params['height'])) {
                $config['types'][$type]['height'] = 100;
            }

            if (!isset($params['crop'])) {
                $config['types'][$type]['crop'] = true;
            }

            if (!isset($params['stretch'])) {
                $config['types'][$type]['stretch'] = false;
            }

            if (!isset($params['watermark'])) {
                $config['types'][$type]['watermark'] = false;
            } elseif (file_exists($params['watermark']) && !is_dir($params['watermark'])) {
                $config['types'][$type]['watermark'] = realpath($params['watermark']);
                if (isset($params['watermark_pos']) && defined('\ysaroka\autothumb\ThumbnailerInterface::POS_' . strtoupper($params['watermark_pos']))) {
                    $config['types'][$type]['watermark_pos'] = constant('\ysaroka\autothumb\ThumbnailerInterface::POS_' . strtoupper($params['watermark_pos']));
                } else {
                    $config['types'][$type]['watermark_pos'] = ThumbnailerInterface::POS_BOTTOM_RIGHT;
                }
            } else {
                throw new ConfigurationException('Image file "watermark": "' . $params['watermark'] . '" for type "' . $type . '" does not exist.');
            }
        }

        if (isset($config['allowed_extensions']) && is_array($config['allowed_extensions']) && count($config['allowed_extensions']) > 0) {
            $this->_allowedExtensions = $config['allowed_extensions'];
        }

        $this->_documentRoot = realpath($config['document_root']);
        $this->_types = $config['types'];

        return $this;
    }
103880
protected function loadConfigurationFile(array $config, XmlFileLoader $loader)
    {
        foreach ($config as $filename) {
            if (file_exists($file = sprintf('%s/%s.xml', $this->getConfigurationDirectory(), $filename))) {
                $loader->load($file);
            }
        }
    }
351330
public function load(Config $config)
    {
        $sys = new Service\SystemService();

        $config->set('CWD', $sys->getCurrentWorkingDirectory());
    }
921684
public static function setConfig($config)
	{
		//set the error file path
		self::$errorFilePath = dirname(dirname(__FILE__)) . '/Exceptions/';

		//set the config array
		self::$config = $config; 

	}
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;
    }