public function loadRuntimeConfig(Output $output)
{
// where is the config file?
$configDir = $this->getConfigDir();
$filename = $configDir . "/" . self::RUNTIME_FILENAME;
// does the file exist?
if (!is_file($filename)) {
return new BaseObject();
}
// at this point, we should be able to load the config
$raw = @file_get_contents($filename);
if (FALSE === $raw) {
$output->logCliError("unable to read config file '{$filename}'; permissions error?");
exit(1);
}
// the config file may be empty
if (strlen(rtrim($raw)) === 0) {
return new BaseObject();
}
$config = @json_decode($raw);
if (NULL === $config) {
$output->logCliError("unable to parse JSON in config file '{$filename}'");
exit(1);
}
// we need to convert the loaded config into our more powerful config
// (at least for now)
$enhancedConfig = new BaseObject();
$enhancedConfig->mergeFrom($config);
// all done
return $enhancedConfig;
}