You are here

public function ConfigUpdateController::diff in Configuration Update Manager 8

Shows the diff between active and provided configuration.

Parameters

string $config_type: The type of configuration.

string $config_name: The name of the config item, without the prefix.

Return value

array Render array for page showing differences between them.

1 string reference to 'ConfigUpdateController::diff'
config_update_ui.routing.yml in config_update_ui/config_update_ui.routing.yml
config_update_ui/config_update_ui.routing.yml

File

config_update_ui/src/Controller/ConfigUpdateController.php, line 126

Class

ConfigUpdateController
Returns responses for Configuration Revert module operations.

Namespace

Drupal\config_update_ui\Controller

Code

public function diff($config_type, $config_name) {
  $diff = $this->configDiff
    ->diff($this->configRevert
    ->getFromExtension($config_type, $config_name), $this->configRevert
    ->getFromActive($config_type, $config_name));
  $build = [];
  $definition = $this->configList
    ->getType($config_type);
  $config_type_label = $definition ? $definition
    ->getLabel() : $this
    ->t('Simple configuration');
  $build['#title'] = $this
    ->t('Config difference for @type @name', [
    '@type' => $config_type_label,
    '@name' => $config_name,
  ]);
  $build['#attached']['library'][] = 'system/diff';
  $build['diff'] = [
    '#type' => 'table',
    '#header' => [
      [
        'data' => $this
          ->t('Source config'),
        'colspan' => '2',
      ],
      [
        'data' => $this
          ->t('Site config'),
        'colspan' => '2',
      ],
    ],
    '#rows' => $this->diffFormatter
      ->format($diff),
    '#attributes' => [
      'class' => [
        'diff',
      ],
    ],
  ];
  $url = new Url('config_update_ui.report');
  $build['back'] = [
    '#type' => 'link',
    '#attributes' => [
      'class' => [
        'dialog-cancel',
      ],
    ],
    '#title' => $this
      ->t("Back to 'Updates report' page."),
    '#url' => $url,
  ];
  return $build;
}