app/library/Services.php: make config service abit more generic (loading any number of files).
This commit is contained in:
parent
3ebd19a8cf
commit
005f1e3292
1 changed files with 19 additions and 6 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Reference in a new issue