You are here

protected function ConfigHandler::getUpdateConfig in Update helper 8

Same name and namespace in other branches
  1. 2.x src/ConfigHandler.php \Drupal\update_helper\ConfigHandler::getUpdateConfig()

Get list of configuration changes with change action (add, delete, change).

Parameters

array $diffs: List of diff edits.

Return value

array Return configuration array that should be applied.

1 call to ConfigHandler::getUpdateConfig()
ConfigHandler::generatePatchFile in src/ConfigHandler.php
Generate patch from changed configuration.

File

src/ConfigHandler.php, line 263

Class

ConfigHandler
Configuration handler.

Namespace

Drupal\update_helper

Code

protected function getUpdateConfig(array $diffs) {
  $list_update = [
    'delete' => [],
    'add' => [],
    'change' => [],
  ];
  foreach ($diffs as $diff_op) {
    if (!empty($diff_op->closing)) {
      if ($diff_op->type === 'change') {
        $removable_edits = $this
          ->getRemovableEdits($diff_op->orig, $diff_op->closing);
        if (!empty($removable_edits)) {
          $list_update['delete'] = array_merge($list_update['delete'], $removable_edits);
        }
      }
      $list_update[$diff_op->type] = array_merge($list_update[$diff_op->type], $diff_op->closing);
    }
    elseif ($diff_op->type === 'delete' && !empty($diff_op->orig)) {
      $list_update[$diff_op->type] = array_merge($list_update[$diff_op->type], $diff_op->orig);
    }
  }
  $list_update = array_filter($list_update);
  foreach ($list_update as $action => $edits) {
    $list_update[$action] = $this->configDiffTransformer
      ->reverseTransform($edits);
  }
  return $list_update;
}