You are here

protected function Updater::applyConfigActions in Update helper 2.x

Same name and namespace in other branches
  1. 8 src/Updater.php \Drupal\update_helper\Updater::applyConfigActions()

Apply configuration changes on configuration array.

Order is following: 1. Delete

  • this options is first, in that way, it's possible to delete bigger configuration block before adding new one.

2. Add

  • add is seconds, in that way we can add whole block deleted before.

3. Change

  • change is last, because we want to apply smaller modifications after all bigger changes are done.

Parameters

array $base_config: The base configuration.

array $update_actions: The configuration update actions.

Return value

array Returns modified configuration.

1 call to Updater::applyConfigActions()
Updater::updateConfig in src/Updater.php
Update configuration.

File

src/Updater.php, line 212

Class

Updater
Helper class to update configuration.

Namespace

Drupal\update_helper

Code

protected function applyConfigActions(array $base_config, array $update_actions) : array {

  // 1. Define configuration keys that should be deleted.
  if (isset($update_actions['delete'])) {
    $delete_keys = $this
      ->getFlatKeys($update_actions['delete']);
    foreach ($delete_keys as $key_path) {
      NestedArray::unsetValue($base_config, $key_path);
    }
  }

  // 2. Add configuration that is added.
  if (isset($update_actions['add'])) {
    $base_config = NestedArray::mergeDeep($base_config, $update_actions['add']);
  }

  // 3. Add configuration that is changed.
  if (isset($update_actions['change'])) {
    $base_config = NestedArray::mergeDeep($base_config, $update_actions['change']);
  }
  return $base_config;
}