Say you have these 2 configs:
$config1 = [
'di' => [
'services' => [
'db' => [
MySQLDB::class,
'arguments' => [
'username',
'password',
'hostname',
],
],
],
],
];
$config2 = [
'di' => [
'services' => [
'db' => [
FileDB::class,
'arguments' => [
'filename',
],
],
],
],
];
When loading the configs like so:
Configurator::apply()
->configFromArray($config1)
->configFromArray($config2)
->to($container);
You end up with a config definition like this:
$config2 = [
'di' => [
'services' => [
'db' => [
FileDB::class,
'arguments' => [
'filename', // from $config2
'password', // from $config1
'hostname', // from $config1
],
],
],
],
];
Sometimes this is desired behaviour, sometimes it is not. I'm trying to decide if this is a problem and how it should be addressed.
Current options:
1. Treat the config as additive only?
Basically, claim that this isn't a problem and replacing services in this way is not the intended use case.
2. Add method to wrap specific sections
For example:
$config2 = [
'di' => [
'services' => [
'db' => Configurator::replace([
FileDB::class,
'arguments' => [
'filename',
],
]),
],
],
];
It's a decent idea but it won't work for non-PHP config files.
Say you have these 2 configs:
When loading the configs like so:
You end up with a config definition like this:
Sometimes this is desired behaviour, sometimes it is not. I'm trying to decide if this is a problem and how it should be addressed.
Current options:
1. Treat the config as additive only?
Basically, claim that this isn't a problem and replacing services in this way is not the intended use case.
2. Add method to wrap specific sections
For example:
It's a decent idea but it won't work for non-PHP config files.