0 follower

Final Class Yiisoft\Config\Modifier\RecursiveMerge

InheritanceYiisoft\Config\Modifier\RecursiveMerge

Enable recursive merge for specified groups.

The modifier should be specified as

RecursiveMerge::groups('params', 'events')

For example:

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

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

The result will be:

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

Method Details

Hide inherited methods

getDepth() public method

public integer|null getDepth ( )

                public function getDepth(): ?int
{
    return $this->depth;
}

            
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);
}

            
groupsWithDepth() public static method

public static self groupsWithDepth ( string[] $groups, integer|null $depth )
$groups string[]
$depth integer|null

                public static function groupsWithDepth(array $groups, ?int $depth): self
{
    return new self($groups, $depth);
}