public function ConfigPatchMerge::mergePatch in Configuration Split 2.0.x
Apply a patch to a config array.
Parameters
array $config: The config data.
\Drupal\config_split\Config\ConfigPatch $patch: The patch object.
string|null $name: The config name to sort it correctly.
Return value
array The changed config data.
File
- src/
Config/ ConfigPatchMerge.php, line 65
Class
- ConfigPatchMerge
- The patch merging service.
Namespace
Drupal\config_split\ConfigCode
public function mergePatch(array $config, ConfigPatch $patch, string $name = NULL) : array {
if ($patch
->isEmpty()) {
return $config;
}
$changed = DiffArray::diffAssocRecursive($config, $patch
->getRemoved());
$changed = NestedArray::mergeDeepArray([
$changed,
$patch
->getAdded(),
], TRUE);
// Make sure not to remove the dependencies key from config entities.
if (isset($config['dependencies']) && !isset($changed['dependencies'])) {
$changed['dependencies'] = [];
}
// Make sure the order of the keys is still the same.
$changed = array_replace(array_intersect_key($config, $changed), $changed);
if ($name !== NULL) {
// Also sort the config if we know the name.
$changed = $this->configSorter
->sort($name, $changed);
}
return $changed;
}