0 follower

Final Class Yiisoft\Config\Modifier\ReverseMerge

InheritanceYiisoft\Config\Modifier\ReverseMerge

Result of reverse merge is being ordered descending by data source. It is useful for merging module config with base config where more specific config (i.e. module's) has more priority.

The modifier should be specified as

ReverseMerge::groups('events', 'events-web', 'events-console')

For example:

  • configuration in application composer.json:
"config-plugin": {
    "events": "events.php",
    "params": "params.php",
}
  • application events.php contents:
return ['a' => 1, 'b' => 2];
  • configuration in vendor package:
"config-plugin": {
    "events": "events.php",
}
  • vendor package events.php contents:
return ['c' => 3, 'd' => 4];
  • getting configuration:
$config = new Config(new ConfigPaths($configsDir), null, [
    ReverseMerge::groups('events'),
]);

$result = $config->get('events');

The result will be:

[
    'a' => 1,
    'b' => 2,
    'c' => 3,
    'd' => 4,
]

Method Details

Hide inherited methods

getGroups() public method

public string[] getGroups ( )

                public function getGroups(): array
{
    return $this->groups;
}

            
groups() public static method

public static self groups ( string $groups )
$groups string

                public static function groups(string ...$groups): self
{
    return new self($groups);
}