Archived
1
0
Fork 0

app/library/Services.php: make config service abit more generic (loading any number of files).

This commit is contained in:
Henrik Hautakoski 2018-06-18 20:21:31 +02:00
parent 3ebd19a8cf
commit 005f1e3292

View file

@ -59,14 +59,27 @@ class Services extends DiDefault
protected function _initSharedConfig()
{
$config = new Config(APP_PATH . '/app/config/conf.app.yml');
// All config files used by the application.
// These will be compiled into a single config object.
//
// The priority is files defined AFTER another
// will override settings if there a multiple keys.
$files = array(
'conf.app.yml',
'conf.local.yml'
);
try {
$local = new Config(APP_PATH . '/app/config/conf.local.yml');
$basePath = APP_PATH . '/app/config/';
$config->merge($local);
} catch(Phalcon\Config\Exception $e) {
// Sometime went wrong.
$config = new \Phalcon\Config();
foreach ($files as $file) {
try {
$config->merge(new Config($basePath . $file));
} catch(\Phalcon\Config\Exception $e) {
// Sometime went wrong. Log here?
}
}
return $config;