Load config file

@param File $config_file
@param ConfigReader $reader

@return array

@throws UnsupportedConfigFileFormatException
491264
private static function loadConfigFileByFormat($config_file, ConfigReader $reader) : array
    {
        $config = null;
        $extension = $config_file->getExtension();
        switch(strtolower($extension)){
            case 'json':
                $config = $reader->readFromFile(new JsonConfigFile($config_file));
                break;
            case 'yml':
            case 'yaml':
                $config = $reader->readFromFile(new YamlConfigFile($config_file));
                break;
            case 'php':
                $config = $reader->readFromFile(new PhpConfigFile($config_file));
                break;
            default:
                throw new UnsupportedConfigFileFormatException($config_file);
        }
        return $config;
    }
1251984
protected function loadConfigFile($file)
    {
        $path = $this->getConfigPath() . '/' . $file;

        if (file_exists($path)) {
            $config = include $path;
            return is_array($config) ? $config : null;
        }

        return null;
    }
1366421
public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = $this->createConfigurationParser();
        $this->globalConfiguration = $this->processConfiguration($configuration, $configs);

        $container->setParameter('sidus_eav_publishing.queue.configuration', $this->globalConfiguration['queue']);

        foreach ($this->globalConfiguration['publishers'] as $code => $publisherConfiguration) {
            $this->createPublisherService($code, $publisherConfiguration, $container);
        }

        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.yml');
    }
310017
public function loadConfiguration(array $configProviders): array
    {
        $rawConfig = [];
        foreach ($configProviders as $configProvider) {
            $rawConfig = array_replace_recursive($rawConfig, $configProvider->readConfiguration());
        }

        return $this->processor->processConfiguration($this->configuration, [Configuration::CONFIG_ROOT => $rawConfig]);
    }
882548
private function loadConfigFile($configFile)
    {
        if ($this->useCache) {
            if (function_exists('apc_fetch')) {
                $config = apc_fetch($configFile);
            } elseif (function_exists('apcu_fetch')) {
                $config = apcu_fetch($configFile);
            }

            if (!empty($config)) {
                return $config;
            }
        }

        if (!is_readable($configFile)) {
            throw new FileNotFoundException("File $configFile could not be found.");
        }

        try {
            $config = $this->parser->parse(file_get_contents($configFile));
        } catch (ParseException $e) {
            $line = $e->getParsedLine();
            throw new InvalidConfigFileException(
                "File $configFile does not have a valid format (line $line)"
            );
        }

        if ($this->useCache) {
            if (function_exists('apc_store')) {
                apc_store($configFile, $config);
            } elseif (function_exists('apcu_store')) {
                apcu_store($configFile, $config);
            }
        }

        return $config;
    }
154316
def load_config(configfile):
    

    configfile = os.path.abspath(configfile)
    config = configobj.ConfigObj(configfile)

    config_extension = '.conf'

    #########################################################################
    # Load up other config files
    #########################################################################

    if 'configs' in config:
        config_extension = config['configs'].get('extension', config_extension)

        # Load other configs
        if 'path' in config['configs']:
            for cfgfile in os.listdir(config['configs']['path']):
                cfgfile = os.path.join(config['configs']['path'],
                                       cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                newconfig = configobj.ConfigObj(cfgfile)
                config.merge(newconfig)

    #########################################################################

    if 'server' not in config:
        raise Exception('Failed to load config file %s!' % configfile)

    #########################################################################
    # Load up handler specific configs
    #########################################################################

    if 'handlers' not in config:
        config['handlers'] = configobj.ConfigObj()

    if 'handlers_config_path' in config['server']:
        handlers_config_path = config['server']['handlers_config_path']
        if os.path.exists(handlers_config_path):
            for cfgfile in os.listdir(handlers_config_path):
                cfgfile = os.path.join(handlers_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                handler = os.path.splitext(filename)[0]

                if handler not in config['handlers']:
                    config['handlers'][handler] = configobj.ConfigObj()

                newconfig = configobj.ConfigObj(cfgfile)
                config['handlers'][handler].merge(newconfig)

    #########################################################################
    # Load up Collector specific configs
    #########################################################################

    if 'collectors' not in config:
        config['collectors'] = configobj.ConfigObj()

    if 'collectors_config_path' in config['server']:
        collectors_config_path = config['server']['collectors_config_path']
        if os.path.exists(collectors_config_path):
            for cfgfile in os.listdir(collectors_config_path):
                cfgfile = os.path.join(collectors_config_path, cfgfile)
                cfgfile = os.path.abspath(cfgfile)
                if not cfgfile.endswith(config_extension):
                    continue
                filename = os.path.basename(cfgfile)
                collector = os.path.splitext(filename)[0]

                if collector not in config['collectors']:
                    config['collectors'][collector] = configobj.ConfigObj()

                try:
                    newconfig = configobj.ConfigObj(cfgfile)
                except Exception as e:
                    raise Exception("Failed to load config file %s due to %s" %
                                    (cfgfile, e))

                config['collectors'][collector].merge(newconfig)

    # Convert enabled to a bool
    for collector in config['collectors']:
        if 'enabled' in config['collectors'][collector]:
            config['collectors'][collector]['enabled'] = str_to_bool(
                config['collectors'][collector]['enabled']
            )

    #########################################################################

    return config
152577
def load_config(config_file)
      config_data = JSON.parse(File.read(config_file))
      return if config_data.nil?
      self.url    = config_data['url']
      @username   = config_data['username']
      @password   = config_data['password']
      @verify_ssl = config_data['verify_ssl']
    end
535541
def read_config_file(file)
      @config_hash = YAML.load_file(file)
      @starting_path = File.expand_path(File.split(file).first)
      @config_options = {}
      load_tags
      load_file_exclusions
      load_extension_inclusions
      config_options
    end
1278321
public function load(array $configs, ContainerBuilder $container)
    {
        $fileSrc = dirname($this->reflector->getFileName()) . $this->xmlFilePath;
        $loader  = new XmlFileLoader($container, new FileLocator($fileSrc));
        $loader->load($this->xmlFileName);
    }
888029
public function open($file, $config = array())
    {
        $fs = new Filesystem();
        $config['TempDir'] = $fs->getAbsolutePath();
        $this->reader = new \SpreadsheetReader_XLSX($file, $config);
    }
1187326
public function config_load($file, $section = null, $scope = 'global')
    {
        $this->ConfigLoad($file, $section, $scope);
    }
1350164
def load_group_config(self, file_id):
        
        if file_id not in self._group_configs:
            self._group_configs[file_id] = self._reader.read_config_file(
                'group_config_%s.cml' % file_id)

        return self._group_configs[file_id]
592021
private function loadXmlFile(string $configFile): array
    {
        $xml = simplexml_load_file($configFile);
        $configArr = [];

        if (isset($xml->name)) {
            $configArr['name'] = (string) $xml->name;
        }

        if (isset($xml->database['name'])) {
            $configArr['database'] = (string) $xml->database['name'];
        }

        if (isset($xml->collection['name'])) {
            $configArr['collection_name'] = (string) $xml->collection['name'];
        }

        if (isset($xml->{'migrations-namespace'})) {
            $configArr['migrations_namespace'] = (string) $xml->{'migrations-namespace'};
        }

        if (isset($xml->{'migrations-directory'})) {
            $configArr['migrations_directory'] = (string) $xml->{'migrations-directory'};
        }

        if (isset($xml->{'migrations-script-directory'})) {
            $configArr['migrations_script_directory'] = (string) $xml->{'migrations-script-directory'};
        }

        if (isset($xml->migrations->migration)) {
            foreach ($xml->migrations->migration as $migration) {
                $configArr['migrations'][] = [
                    'version' => $migration['version'],
                    'class' => $migration['class'],
                ];
            }
        }

        return $configArr;
    }
1134374
protected function _load()
    {
        $file = new File($this->_file, "r");

        $data = @parse_ini_string($file->read(), true);
        if ($data === false) {
            throw new Exception\ParserErrorException(
                "Error parsing configuration file {$this->_file}"
            );
        }
        $this->_data = $data;
    }
99808
protected function parse(\SplFileInfo $file): array
    {
        try {
            $config = (new Parser())->parseFile($file->getRealPath());
        } catch (ParseException $e) {
            throw new ConfigurationParseException('Unable to parse config file: ' . $e->getMessage());
        }

        return $config;
    }
1153546
public function load($file, $namespace = '', $parser = null, $env = null)
    {
        $config = [];

        $this->currentFile = $file;

        //~ Check in cache
        if (is_object($this->cache)) {
            $config = $this->cache->get('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache');
        }

        //~ If not in cache or cache object not defined
        if (empty($config)) {

            if (!file_exists($file)) {
                throw new \Exception('Configuration file does not exists !');
            }

            $config = $parser->load($file);

            if ($env !== null) {
                $configTmp = [];

                //~ Firstable, pick section 'all' from config if section exists.
                if (isset($config['all']) && is_array($config['all'])) {
                    $configTmp = $config['all'];
                }

                //~ Secondly, merge recursively with section corresponding with environment if section exists.
                if (isset($config[$env]) && is_array($config[$env])) {
                    $configTmp = array_replace_recursive($configTmp, $config[$env]);
                }

                //~ Set merged configurations into main array.
                $config = $configTmp;
            }

            if (is_object($this->cache)) {
                $this->cache->set('Eureka.Component.Config.Test.' . $env . '.' . md5($file) . '.cache', $config);
            }
        }

        $this->add($namespace, $config);

        $this->currentFile = '';

        return $this;
    }
700004
public static Config loadConfig(Reader configReader, boolean useSystemEnvironment) {
        return loadConfig(ConfigParseOptions.defaults(),
                ConfigResolveOptions.defaults().setUseSystemEnvironment(useSystemEnvironment),
                configReader);
    }