Hey guys,
I am new here and I hope you can give me some food for thoughts. I am developing a php system which can be extended by various extensions. Each extension has its own extension directory with a bundle of different classes (e.g. service classes) and sub directories. One of the sub directory is the configuration directory of the extension. Each extension may provide custom configurations and should be able to overwrite maybe a small set of configuration items of another extension. I am sure this concept may cause some snares but it is a requirement. A configuration file is a php file which returns an array. Let us be more precise and consider the following example.
cache.php
[php]return [
‘cache’ => [
‘lifetime’ => 3600,
‘logger’ => [
‘cacheEntryAddedLogger’
]
]
];[/php]
This simple configuration is provided by an extension x. What if another extension y requires the extension x and must overwrite the provided configuration file? The other extension should provide a configuration file with the same name but with different contents.
cache.php
[php]return [
‘cache’ => [
‘lifetime’ => 3600,
‘logger’ => [
‘cacheEntryRetrievalLogger’
]
]
];[/php]
In case of the ‘lifetime’ parameter its quite simple. Just replace the value (replace the array value of the key). In case of the ‘logger’ parameter I am not sure how to manage this with arrays. A developer could have at least two options of intensions.
a) Append the ‘logger’ array entries from the overwriting configuration file
b) Replace the ‘logger’ array with the array from the overwriting configuration file
Do you have any idea how I can manage this to support both the appending and the replacement of array configuration items? I hope I illustrated my problem understandable.
Thank you for your help