Add fallback config loading with custom overrides
This commit is contained in:
parent
ca91a18cb7
commit
f0d50ff8bf
1 changed files with 11 additions and 5 deletions
|
|
@ -1,11 +1,17 @@
|
|||
<?php
|
||||
|
||||
function createContext(): Context {
|
||||
// Load configuration
|
||||
$configFile = file_exists(__DIR__ . '/../custom/config.ini')
|
||||
? __DIR__ . '/../custom/config.ini'
|
||||
: __DIR__ . '/config.ini';
|
||||
$config = parse_ini_file($configFile, true);
|
||||
// Load configuration with fallback: custom -> default
|
||||
$defaultConfig = __DIR__ . '/default/config.ini';
|
||||
$customConfig = __DIR__ . '/../custom/config.ini';
|
||||
|
||||
// Start with default config
|
||||
$config = file_exists($defaultConfig) ? parse_ini_file($defaultConfig, true) : [];
|
||||
|
||||
// Merge with custom config if it exists
|
||||
if (file_exists($customConfig)) {
|
||||
$config = array_replace_recursive($config, parse_ini_file($customConfig, true) ?: []);
|
||||
}
|
||||
|
||||
// Load global plugins
|
||||
getPluginManager()->loadGlobalPlugins($config);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue