@param array  $config   Config
@param string $pathname Configuration file pathname

@return array
@throws \Darvin\AdminBundle\Metadata\Configuration\ConfigurationException
12856
private function processConfiguration(array $config, $pathname)
    {
        $processor = new Processor();

        try {
            return $this->parameterBag->resolveValue($processor->processConfiguration(new Configuration(), $config));
        } catch (InvalidConfigurationException $ex) {
            throw new ConfigurationException(
                sprintf('Configuration file "%s" is invalid: "%s".', $pathname, $ex->getMessage())
            );
        }
    }
1224131
protected function doSetup($config = array())
    {
        // Catch the configuration file path
        if (isset($config[self::CONFIG_KEY_FILE_PATH])) {
            $this->configFilePath = $config[self::CONFIG_KEY_FILE_PATH];
        } else {
            // Also consider throwing an exception here instead
            // of failing silently
            return $config;
        }

        // Catch the context
        if (isset($config[ConfigInterface::KEY_CONTEXT])) {
            $this->context = $config[ConfigInterface::KEY_CONTEXT];
        }

        return $this->readConfigurationFiles();
    }
840052
public function findConfigurationFile($filename = null, $pwd = null)
    {
        $filename = $filename ?: $this->getConfigurationFileName();
        $pwd = $pwd ?: getcwd();
        
        $dirs = explode(DS, $pwd);
        $find = false;
        do {
            $dir = join(DS, $dirs);
            $config_file_path = $dir . DS . $filename;
            if (file_exists($config_file_path) && is_file($config_file_path))
                return $config_file_path;
        } while (array_pop($dirs));

        return $pwd . DS . $filename;
    }
106371
public function addFromConfig(array $config)
    {
        foreach ($config as $name => $data) {
            $params     = isset($data['params']) ? $data['params'] : array();
            $parameters = array();
            foreach ($params as $nameParam => $param) {
                if (empty($params['type'])) {
                    $params['type'] = 'string';
                }

                switch ($param['type']) {

                    case 'int':
                        $param['type'] = Parameter::TYPE_INTEGER;
                        break;

                    case 'mixed':
                        $param['type'] = Parameter::TYPE_MIXED;
                        break;

                    case 'string':
                        $param['type'] = Parameter::TYPE_STRING;
                        break;

                    default:
                        // Consider  current value as regexp
                }
                $parameters[$nameParam] = new Parameter($nameParam, $param['type'], (bool) $param['mandatory']);
            }
            $this->add(new Route($name, $data['route'], $data['controller'], $parameters));
        }

        return $this;
    }
1220869
protected function mergeFileContent(string $pathAndFilename, array $configuration): array
    {
        if (!is_file($pathAndFilename)) {
            return $configuration;
        }

        try {
            $yaml = file_get_contents($pathAndFilename);
            if ($this->usePhpYamlExtension) {
                $loadedConfiguration = @yaml_parse($yaml);
                if ($loadedConfiguration === false) {
                    throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '".', 1391894094);
                }
            } else {
                $loadedConfiguration = Yaml::parse($yaml);
            }
            unset($yaml);

            if (is_array($loadedConfiguration)) {
                $configuration = Arrays::arrayMergeRecursiveOverrule($configuration, $loadedConfiguration);
            }
        } catch (Exception $exception) {
            throw new ParseErrorException('A parse error occurred while parsing file "' . $pathAndFilename . '". Error message: ' . $exception->getMessage(), 1232014321);
        }

        return $configuration;
    }
669824
public function updateConfigToFile($fileName, Configuration $config)
    {
        $configArray = [
            'api_key' => $config->getApiKey(),
            'api_uri' => $config->getApiUri(),
            'organization' => $config->getOrganizationName() ? $config->getOrganizationName() : '',
        ];

        $yml = [];
        if (file_exists($fileName)) {
            $yml = Yaml::parse(file_get_contents($fileName));
        }

        $yml = array_merge($yml, ['rokka_cli' => $configArray]);

        return file_put_contents($fileName, Yaml::dump($yml));
    }
966032
protected function parseConfig(string $config): array
    {
        $config = json_decode($config, true);
        if ($config === null) {
            throw new ConfigFileFormatException("Config files should be written in valid JSON");
        }
        return $config;
    }
860505
public static function config_get_configuration_array($data) {
        $config = array();

        if (isset($data->path)) {
            $config['path'] = $data->path;
        }
        if (isset($data->autocreate)) {
            $config['autocreate'] = $data->autocreate;
        }
        if (isset($data->singledirectory)) {
            $config['singledirectory'] = $data->singledirectory;
        }
        if (isset($data->prescan)) {
            $config['prescan'] = $data->prescan;
        }

        return $config;
    }
123254
private function __buildConfig(array $config)
    {
        foreach ($config as $key => $conf) {
            if ($key == 'driver') {
                $this->rawConfig['type'] = strtolower($conf);
                continue;
            }

            if (!array_key_exists($key, $this->rawConfig)) {
                $this->error->setMessage(sprintf(
                    "invalid config '%s', allowed config are: %s",
                    $key, implode(', ', array_keys($this->rawConfig))
                ));
                break;
            }

            $this->rawConfig[$key] = $conf;
        }

        if (!$this->error->hasError() && !$this->hasDriver($this->getType()) && !$this->preventNoLocalDriver) {
            $this->error->setMessage(sprintf(
                "Driver '%s' not available. Please choose one of: '%s'. ".
                'Or register new ConnectionString class by implements %s.',
                $this->getType(),
                implode("', '", $this->getAvailableDrivers()),
                ConnectionStringInterface::class
            ));
        }
    }
826312
private function configureCommand($paths, $config)
    {
        // options
        foreach ($config['command']['options'] as $name => $option) {
            $this->addOption($name, $option);
        }

        // commands
        $commands = CommandLine\Commands::getInstance()
                            ->setPath($paths['configs'] . 'commands');
        foreach ($commands as $name => $data) {
            $this->registerCommand($name, $data);

        }

        return $this;
    }
935914
protected function _set( $config, $path, $value )
	{
		if( ( $current = array_shift( $path ) ) !== null )
		{
			if( isset( $config[$current] ) ) {
				$config[$current] = $this->_set( $config[$current], $path, $value );
			} else {
				$config[$current] = $this->_set( array(), $path, $value );
			}

			return $config;
		}

		return $value;
	}
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;
    }
166839
static public function config($config = array())
    {
        !empty($config) && self::$config = array_merge(self::$config, $config);
        if (!empty(self::$config['cachepath'])) {
            Cache::$cachepath = self::$config['cachepath'];
        }
        if (empty(self::$config['component_verify_ticket'])) {
            self::$config['component_verify_ticket'] = Cache::get('component_verify_ticket');
        }
        if (empty(self::$config['token']) && !empty(self::$config['component_token'])) {
            self::$config['token'] = self::$config['component_token'];
        }
        if (empty(self::$config['appsecret']) && !empty(self::$config['component_appsecret'])) {
            self::$config['appsecret'] = self::$config['component_appsecret'];
        }
        if (empty(self::$config['encodingaeskey']) && !empty(self::$config['component_encodingaeskey'])) {
            self::$config['encodingaeskey'] = self::$config['component_encodingaeskey'];
        }
        return self::$config;
    }
1147693
public static function configure($config = [])
    {
        if (empty(static::$config)) {
            static::$config = $config;
        }

        if (!in_array($config['driver'], ["smtp", "mail"])) {
            throw new MailException("The type is not known.", E_USER_ERROR);
        }

        if ($config['driver'] == "mail") {
            if (!static::$instance instanceof Native) {
                static::$instance = new Native($config['mail']);
            }
        } else {
            if (!static::$instance instanceof Smtp) {
                static::$instance = new Smtp($config['smtp']);
            }
        }

        return static::$instance;
    }
1037643
private function filter(array $config): array
    {
        $filteredConfig = $config;
        if (!empty($config['app_root'])) {
            $filteredConfig['app_root'] = rtrim($config['app_root'], '/');
        }

        if (!empty($config['relative_document_root'])) {
            $filteredConfig['relative_document_root'] = rtrim($config['relative_document_root'], '/');
        }

        if (!empty($config['default_file_mode'])) {
            if (is_string($config['default_file_mode'])) {
                $filteredConfig['default_file_mode'] = octdec($config['default_file_mode']);
            } else {
                $filteredConfig['default_file_mode'] = (int)$config['default_file_mode'];
            }
        }

        if (!empty($config['default_dir_mode'])) {
            if (is_string($config['default_dir_mode'])) {
                $filteredConfig['default_dir_mode'] = octdec($config['default_dir_mode']);
            } else {
                $filteredConfig['default_dir_mode'] = (int)$config['default_dir_mode'];
            }
        }
        return $filteredConfig;
    }
409525
public function getConfigurationOptions($configurationName)
    {
        if (!array_key_exists($configurationName, $this->configurations)) {
            $errMsg = sprintf('Invalid configuration name %s', $configurationName);
            throw new Exception\InvalidConfigurationNameException($errMsg);
        }

        return new ConfigurationOptions($this->configurations[$configurationName]);
    }
897469
public static function getConfig(array $appConfig = []) : array
  {
    $configs = DEPConfig::$appdir . 'config' . DIRECTORY_SEPARATOR . '*.php';

    foreach (\glob($configs) as $config) {
      $service = require $config;

      if (is_array($service)) {
        $path = basename($config);
        $name = \substr($path, 0, strlen($path) - 4);
        $appConfig = array_merge($appConfig, [$name => $service]);
      }
    }

    return $appConfig;
  }