mirror of
https://github.com/friendica/friendica
synced 2024-12-22 18:40:17 +00:00
Refactor ConfigFileManager
This commit is contained in:
parent
cde93c68dc
commit
58e447f7bb
1 changed files with 48 additions and 46 deletions
|
@ -245,59 +245,61 @@ class ConfigFileManager
|
|||
$fullName = $this->baseDir . DIRECTORY_SEPARATOR . '.' . $name . '.php';
|
||||
|
||||
$config = [];
|
||||
if (file_exists($fullName)) {
|
||||
$a = new \stdClass();
|
||||
$a->config = [];
|
||||
include $fullName;
|
||||
if (!file_exists($fullName)) {
|
||||
return $config;
|
||||
}
|
||||
|
||||
$htConfigCategories = array_keys($a->config);
|
||||
$a = new \stdClass();
|
||||
$a->config = [];
|
||||
include $fullName;
|
||||
|
||||
// map the legacy configuration structure to the current structure
|
||||
foreach ($htConfigCategories as $htConfigCategory) {
|
||||
if (is_array($a->config[$htConfigCategory])) {
|
||||
$keys = array_keys($a->config[$htConfigCategory]);
|
||||
$htConfigCategories = array_keys($a->config);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$config[$htConfigCategory][$key] = $a->config[$htConfigCategory][$key];
|
||||
}
|
||||
} else {
|
||||
$config['config'][$htConfigCategory] = $a->config[$htConfigCategory];
|
||||
// map the legacy configuration structure to the current structure
|
||||
foreach ($htConfigCategories as $htConfigCategory) {
|
||||
if (is_array($a->config[$htConfigCategory])) {
|
||||
$keys = array_keys($a->config[$htConfigCategory]);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$config[$htConfigCategory][$key] = $a->config[$htConfigCategory][$key];
|
||||
}
|
||||
} else {
|
||||
$config['config'][$htConfigCategory] = $a->config[$htConfigCategory];
|
||||
}
|
||||
}
|
||||
|
||||
unset($a);
|
||||
unset($a);
|
||||
|
||||
if (isset($db_host)) {
|
||||
$config['database']['hostname'] = $db_host;
|
||||
unset($db_host);
|
||||
}
|
||||
if (isset($db_user)) {
|
||||
$config['database']['username'] = $db_user;
|
||||
unset($db_user);
|
||||
}
|
||||
if (isset($db_pass)) {
|
||||
$config['database']['password'] = $db_pass;
|
||||
unset($db_pass);
|
||||
}
|
||||
if (isset($db_data)) {
|
||||
$config['database']['database'] = $db_data;
|
||||
unset($db_data);
|
||||
}
|
||||
if (isset($config['system']['db_charset'])) {
|
||||
$config['database']['charset'] = $config['system']['db_charset'];
|
||||
}
|
||||
if (isset($pidfile)) {
|
||||
$config['system']['pidfile'] = $pidfile;
|
||||
unset($pidfile);
|
||||
}
|
||||
if (isset($default_timezone)) {
|
||||
$config['system']['default_timezone'] = $default_timezone;
|
||||
unset($default_timezone);
|
||||
}
|
||||
if (isset($lang)) {
|
||||
$config['system']['language'] = $lang;
|
||||
unset($lang);
|
||||
}
|
||||
if (isset($db_host)) {
|
||||
$config['database']['hostname'] = $db_host;
|
||||
unset($db_host);
|
||||
}
|
||||
if (isset($db_user)) {
|
||||
$config['database']['username'] = $db_user;
|
||||
unset($db_user);
|
||||
}
|
||||
if (isset($db_pass)) {
|
||||
$config['database']['password'] = $db_pass;
|
||||
unset($db_pass);
|
||||
}
|
||||
if (isset($db_data)) {
|
||||
$config['database']['database'] = $db_data;
|
||||
unset($db_data);
|
||||
}
|
||||
if (isset($config['system']) && isset($config['system']['db_charset'])) {
|
||||
$config['database']['charset'] = $config['system']['db_charset'];
|
||||
}
|
||||
if (isset($pidfile)) {
|
||||
$config['system']['pidfile'] = $pidfile;
|
||||
unset($pidfile);
|
||||
}
|
||||
if (isset($default_timezone)) {
|
||||
$config['system']['default_timezone'] = $default_timezone;
|
||||
unset($default_timezone);
|
||||
}
|
||||
if (isset($lang)) {
|
||||
$config['system']['language'] = $lang;
|
||||
unset($lang);
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
|
Loading…
Reference in a new issue