You are here

protected function ConfigHandler::getConfigDiff in Update helper 2.x

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

Get diff for single configuration.

Parameters

\Drupal\update_helper\ConfigName $config_name: Configuration name.

bool $from_active: Flag if configuration should be updated from active to file configs.

Return value

\Drupal\Component\Diff\Engine\DiffOp[] Return diff edits.

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

File

src/ConfigHandler.php, line 185

Class

ConfigHandler
Configuration handler.

Namespace

Drupal\update_helper

Code

protected function getConfigDiff(ConfigName $config_name, $from_active) {
  $active_config = $this
    ->getConfigFrom($this->configReverter
    ->getFromActive($config_name
    ->getType(), $config_name
    ->getName()));
  $file_config = $this
    ->getConfigFrom($this->configReverter
    ->getFromExtension($config_name
    ->getType(), $config_name
    ->getName()));
  if (!$this->configDiffer
    ->same($file_config, $active_config)) {
    if ($from_active) {
      $update_diff = $this->configDiffer
        ->diff($active_config, $file_config);
    }
    else {
      $update_diff = $this->configDiffer
        ->diff($file_config, $active_config);
    }

    /** @var \Drupal\Component\Diff\Engine\DiffOp[] $edits */
    return $update_diff
      ->getEdits();
  }
  return [];
}