Loads YAML config file into cache

@throws \BadMethodCallException       If called before setConfigPath()
@throws \RuntimeException             If config file does not exist
@throws Yaml\Exception\ParseException If could not load config file
518768
protected function loadConfig()
    {
        if (self::$config_path === null) {
            throw new \BadMethodCallException('Config path is null');
        }

        $key = "$this->cnab/$this->bank_code";

        if (!array_key_exists($key, self::$cache)) {
            $config_file = self::$config_path . "/cnab$key.yml";
            if (file_exists($config_file)) {
                self::$cache[$key] = Yaml::parseFile($config_file);
            } else {
                throw new \RuntimeException(sprintf(
                    "Config file for Bank '%s' in CNAB%s not found",
                    $this->bank_code,
                    $this->cnab
                ));
            }
        }

        $this->config = $key;
    }
184664
public function loadConfiguration()
    {
        $fileList = $this->buildFileList($this->fileDirectories, $this->fileNames);

        $this->parseConfigurationFiles($fileList);

        $this->mergeConfigurationOption($this->_config, 'configurationPaths', $this->fileDirectories);
    }
710664
public function loadConfig()
    {
        // Load / create config file
        if (file_exists($this->baseDir . '/examples/config.php')) {
            include_once($this->baseDir . '/examples/config.php');
        } else {
            define('SECRET', readline('Secret: '));
            define('API_HOST', readline('Api host: '));

            $configTemplate = "<?php" . PHP_EOL
                . "define('SECRET', %s);" . PHP_EOL
                . "define('API_HOST', %s);" . PHP_EOL;

            file_put_contents(
                $this->baseDir . '/examples/config.php',
                sprintf(
                    $configTemplate,
                    var_export(SECRET, true),
                    var_export(API_HOST, true)
                )
            );
        }
    }
104779
public static function loadConfiguration()
    {
        $defaultsFile = __DIR__ . '/../../../../app/config/defaults.yml';
        $draggyFile   = __DIR__ . '/../../../../app/config/draggy.yml';
        $userFile     = __DIR__ . '/../../../../app/config/user.yml';

        $defaultsArray = Yaml::parse($defaultsFile);

        $configurationArray = is_file($userFile)
            ? Yaml::parse($userFile)
            : Yaml::parse($draggyFile);

        $mergedArray = self::mergeConfigurations($defaultsArray, $configurationArray);

        return $mergedArray;
    }
1022388
private function loadConfigFiles(ContainerBuilder $container): void
    {
        $loader = new YamlFileLoader(
            $container,
            new FileLocator(__DIR__ . '/../Resources/config')
        );

        $loader->load('default_settings.yml');
        $loader->load('services/errors.yml');
        $loader->load('services/view/providers.yml');
        $loader->load('services/view/matchers.yml');
        $loader->load('services/view/view.yml');

        $loader->load('services/items.yml');
        $loader->load('services/block_definitions.yml');
        $loader->load('services/config_definitions.yml');
        $loader->load('services/forms.yml');
        $loader->load('services/context.yml');
        $loader->load('services/commands.yml');
        $loader->load('services/design.yml');
        $loader->load('services/security.yml');
        $loader->load('services/utils.yml');

        $loader->load('services/layout_resolver/layout_resolver.yml');
        $loader->load('services/layout_resolver/condition_types.yml');
        $loader->load('services/layout_resolver/target_handlers.yml');
        $loader->load('services/layout_resolver/target_types.yml');
        $loader->load('services/layout_resolver/forms.yml');

        $loader->load('browser/services.yml');
        $loader->load('services/layouts.yml');
        $loader->load('services/collections.yml');
        $loader->load('services/param_converters.yml');
        $loader->load('services/event_listeners.yml');

        $loader->load('services/configuration.yml');
        $loader->load('services/controllers.yml');
        $loader->load('services/normalizers.yml');
        $loader->load('services/validators.yml');
        $loader->load('services/templating.yml');
        $loader->load('services/parameters.yml');
        $loader->load('services/http_cache.yml');
        $loader->load('services/locale.yml');

        $loader->load('services/transfer/serialization_visitors.yml');
        $loader->load('services/transfer/services.yml');

        $loader->load('services/api.yml');
    }
181561
def load_config(configfile):
    
    try:
        with open(configfile, 'r') as ymlfile:
            try:
                config = yaml.load(ymlfile)
                return config
            except yaml.parser.ParserError:
                raise PyYAMLConfigError(
                    'Could not parse config file: {}'.format(configfile),
                )
    except IOError:
        raise PyYAMLConfigError(
            'Could not open config file: {}'.format(configfile),
        )
460235
def load(self, file=CONFIG_FILE):
        
        if not os.path.exists(file):
            print("Config file was not found under %s. Default file has been created" % CONFIG_FILE)
            self._settings = yaml.load(DEFAULT_CONFIG, yaml.RoundTripLoader)
            self.save(file)
            sys.exit()
        with open(file, 'r') as f:
            self._settings = yaml.load(f, yaml.RoundTripLoader)
818086
def load_conf(cnf) # :nodoc:

      if cnf.nil? or cnf.empty? 
        raise RepoAccessError, 'No config file provided!'
      elsif cnf and cnf.class == String and File.exists? cnf
        @svn_repo_config_file = cnf
        cnf = IO.read(cnf)
      end

      begin
        YAML::load(cnf)
       rescue Exception => e
        raise RepoAccessError, e.message
      end
    end
1360038
private function loadCore(ContainerBuilder $container, Loader\YamlFileLoader $loader, $config)
    {
        $isCacheEnabled = $config['metadata_cache'];

        $container->setParameter('ma27_api_key_authentication.model_name', $config['model_name']);
        $container->setParameter('ma27_api_key_authentication.object_manager', $config['object_manager']);
        $container->setParameter('ma27_api_key_authentication.property.apiKeyLength', $config['api_key_length']);
        $container->setParameter('ma27_api_key_authentication.metadata_cache_enabled', $isCacheEnabled);

        if ($isCacheEnabled) {
            $loader->load('metadata_cache_warmer.yml');
        }

        $this->loadPassword($container, $config['password'], $loader);
    }
1268572
def load_yaml_config(self, conf):
        """"""
        with open(conf) as fd:
            self.config = recursive_dict_update(self.config, yaml.load(fd, Loader=UnsafeLoader))
232968
protected function loadFile($file)
    {
        if (!class_exists('zxf\Symfony\Component\Yaml\Parser')) {
            throw new RuntimeException('Unable to load YAML config files as the Symfony Yaml Component is not installed.');
        }

        if (!stream_is_local($file)) {
            throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
        }

        if (!file_exists($file)) {
            throw new InvalidArgumentException(sprintf('The file "%s" does not exist.', $file));
        }

        if (null === $this->yamlParser) {
            $this->yamlParser = new YamlParser();
        }

        $prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) {
            $message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message;

            return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
        });

        try {
            $configuration = $this->yamlParser->parseFile($file, Yaml::PARSE_CONSTANT | Yaml::PARSE_CUSTOM_TAGS);
        } catch (ParseException $e) {
            throw new InvalidArgumentException(sprintf('The file "%s" does not contain valid YAML.', $file), 0, $e);
        } finally {
            restore_error_handler();
        }

        return $this->validate($configuration, $file);
    }
337714
public function configure()
    {
        if (!file_exists($this->file) || !is_readable($this->file)) {
            throw new RuntimeException(sprintf('The file "%s" does not exists or is not readable.', $this->file));
        }

        try {
            $parser = new Parser();
            $config = $parser->parse(file_get_contents($this->file));
        } catch (ParseException $exception) {
            throw new RuntimeException(sprintf('Error parsing the file "%s".', $this->file));
        }

        if (array_key_exists('magephp', $config) && is_array($config['magephp'])) {
            $logger = null;
            if (array_key_exists('log_dir', $config['magephp']) && file_exists($config['magephp']['log_dir']) && is_dir($config['magephp']['log_dir'])) {
                $logfile = sprintf('%s/%s.log', $config['magephp']['log_dir'], date('Ymd_His'));
                $config['magephp']['log_file'] = $logfile;

                $logger = new Logger('magephp');
                $logger->pushHandler(new StreamHandler($logfile));

            } elseif (array_key_exists('log_dir', $config['magephp']) && !is_dir($config['magephp']['log_dir'])) {
                throw new RuntimeException(sprintf('The configured log_dir "%s" does not exists or is not a directory.', $config['magephp']['log_dir']));
            }

            $this->runtime->setConfiguration($config['magephp']);
            $this->runtime->setLogger($logger);
            return;
        }

        throw new RuntimeException(sprintf('The file "%s" does not have a valid Magallanes configuration.', $this->file));
    }
91015
private function loadConfig()
    {
        $cacheName = $this->mode . '_Phavour_Application_config';
        if (false != ($configs = $this->cache->get($cacheName))) {
            // @codeCoverageIgnoreStart
            $this->config = $configs;
            return;
            // @codeCoverageIgnoreEnd
        }

        $config = array();

        foreach ($this->packagesMetadata as $package) {
            try {
                $finder = new FromArray($package['config_path']);
                $proposedConfig = $finder->getArrayWhereKeysBeginWith($package['package_name']);
                if (is_array($proposedConfig)) {
                    $config = array_merge($config, $proposedConfig);
                }
            } catch (\Exception $e) {
                // Package doesn't have config
            }
        }

        try {
            $finder = new FromArray(
                $this->appDirectory . DIRECTORY_SEPARATOR . 'res' . DIRECTORY_SEPARATOR . 'config.php'
            );
            $appConfig = $finder->getArray();
            if (is_array($appConfig)) {
                $config = array_merge($config, $appConfig);
            }
        } catch (\Exception $e) {
            // No config overrides set
        }

        $this->config = $config;
        $this->cache->set($cacheName, $this->config, 86400);
    }
1024567
private static function initializeConfigurations()
    {
        if (!is_readable(self::CONFIGURATION_PATH)) {
            throw new \RuntimeException("Cannot parse configurations file (config.ini)");
        }
        self::$configurationFile = new ConfigurationFile(self::CONFIGURATION_PATH);
    }
536446
def _load_yaml_config(self):
        
        try:
            config = self._read_config()
        except OSError as error:
            raise ValueError('Could not read configuration file: %s' % error)
        try:
            return yaml.safe_load(config)
        except yaml.YAMLError as error:
            message = '\n'.join(['    > %s' % line
                                 for line in str(error).split('\n')])
            sys.stderr.write('\n\n  Error in the configuration file:\n\n'
                             '{}\n\n'.format(message))
            sys.stderr.write('  Configuration should be a valid YAML file.\n')
            sys.stderr.write('  YAML format validation available at '
                             'http://yamllint.com\n')
            raise ValueError(error)
522779
public function loadFixtures()
    {
        // Using Live Environment?
        
        if ($this->loadFixturesDisabled()) {
            return;
        }
        
        // Initialise:
        
        $errored = false;
        
        // Load Fixture Files:
        
        foreach ($this->config()->fixtures as $file) {
            
            try {
                
                // Attempt Fixture Loading:
                
                YamlFixture::create($file)->writeInto($this->factory);
                
            } catch (Exception $e) {
                
                $errored = true;
                
                $message = $e->getMessage();
                
                if (strpos($message, 'YamlFixture::') === 0 && strpos($message, 'not found') !== false) {
                    $message = sprintf('Cannot load fixture file: %s', $file);
                }
                
                DB::alteration_message(
                    sprintf(
                        'App fixture loading failed with exception: "%s"',
                        $message
                    ),
                    'error'
                );
                
            }
            
        }
        
        if (!$errored) {
            
            // Update App Status:
            
            $this->FixturesLoaded = true;
            
            // Record App Status:
            
            $this->write();
            
        }
    }
1137130
public function load()
    {
        $config = new UserConfiguration();
        if (!file_exists($this->storagePath)) {
            return $config;
        }

        try {
            $data = Yaml::parse(file_get_contents($this->storagePath));
        } catch (ParseException $e) {
            throw new ConfigException(sprintf('The config file "%s" is not a valid YAML.', $this->storagePath), 0, $e);
        }

        if (is_array($data)) {
            $config->load($data);
        }

        return $config;
    }