protected function initConfig()
{
$this->di->setShared('config', function () {
$path = BASE_DIR . 'app/config/';
if (!is_readable($path . 'config.php')) {
throw new RuntimeException('Unable to read config from ' . $path . 'config.php');
}
$config = (include $path . 'config.php');
if (is_array($config)) {
$config = new Config($config);
}
if (!$config instanceof Config) {
$type = gettype($config);
if ($type == 'boolean') {
$type .= $type ? ' (true)' : ' (false)';
} elseif (is_object($type)) {
$type = get_class($type);
}
throw new RuntimeException(sprintf('Unable to read config file. Config must be either an array or Phalcon\\Config instance. Got %s', $type));
}
if (is_readable($path . APPLICATION_ENV . '.php')) {
$override = (include_once $path . APPLICATION_ENV . '.php');
if (is_array($override)) {
$override = new Config($override);
}
if ($override instanceof Config) {
$config->merge($override);
}
}
return $config;
});
}