protected function readConfigFiles($configFile, $additionalOptions)
{
$appConfigPath = App::appConfigPath();
$configPath = App::configPath();
// this is the defaultconfig file of JELIX itself
$config = IniFileMgr::read(__DIR__ . '/defaultconfig.ini.php', true);
// read the main configuration of the app
$mcf = App::mainConfigFile();
if ($mcf) {
IniFileMgr::readAndMergeObject($mcf, $config);
}
$this->commonConfig = clone $config;
if (!file_exists($appConfigPath . $configFile) && !file_exists($configPath . $configFile)) {
if ($additionalOptions) {
IniFileMgr::mergeIniObjectContents($config, $additionalOptions);
return $config;
}
throw new Exception("Configuration file of the entrypoint is missing -- {$configFile}", 5);
}
// read the static configuration specific to the entry point
if ($configFile == 'mainconfig.ini.php') {
throw new Exception("Entry point configuration file cannot be mainconfig.ini.php", 5);
}
// read the local configuration of the app
if (file_exists($configPath . 'localconfig.ini.php')) {
IniFileMgr::readAndMergeObject($configPath . 'localconfig.ini.php', $config);
}
if (file_exists($appConfigPath . $configFile)) {
if (false === IniFileMgr::readAndMergeObject($appConfigPath . $configFile, $config)) {
throw new Exception("Syntax error in the configuration file -- {$configFile}", 6);
}
}
// read the local configuration of the entry point
if (file_exists($configPath . $configFile)) {
if (false === IniFileMgr::readAndMergeObject($configPath . $configFile, $config)) {
throw new Exception("Syntax error in the configuration file -- {$configFile}", 6);
}
}
if ($additionalOptions) {
IniFileMgr::mergeIniObjectContents($config, $additionalOptions);
}
return $config;
}