You are here

public function ConfigUpdateUiCliService::diff in Configuration Update Manager 8

Displays a diff of a config item.

Displays line-by-line differences for one config item between your active config and the version currently being provided by an installed module, theme, or install profile.

Parameters

string $name: The config item to diff. See config-different-report to list config items that are different.

Return value

string The formatted diff output.

File

config_update_ui/src/ConfigUpdateUiCliService.php, line 218

Class

ConfigUpdateUiCliService
Handles all the logic for commands for various versions of Drush.

Namespace

Drupal\config_update_ui

Code

public function diff($name) {
  $extension = $this->configUpdate
    ->getFromExtension('', $name);
  $active = $this->configUpdate
    ->getFromActive('', $name);
  if ($extension && $active) {
    $diff = $this->configDiff
      ->diff($extension, $active);

    // Drupal\Component\Diff\DiffFormatter does not expose a service so we
    // instantiate it manually here.
    $diffFormatter = new DiffFormatter();
    $output = $diffFormatter
      ->format($diff);
    return $output;
  }
  else {
    $this->logger
      ->error(dt('Config is missing, cannot diff.'));
  }
}