public function ConfigController::diff

Shows diff of specificed configuration file.

Parameters

string $config_file: The name of the configuration file.

Return value

string Table showing a two-way diff between the active and staged configuration.

1 string reference to 'ConfigController::diff'
config.routing.yml in drupal/core/modules/config/config.routing.yml
drupal/core/modules/config/config.routing.yml

File

drupal/core/modules/config/lib/Drupal/config/Controller/ConfigController.php, line 79
Contains \Drupal\config\Controller\ConfigController

Class

ConfigController
Returns responses for config module routes.

Namespace

Drupal\config\Controller

Code

public function diff($config_file) {

  // Add the CSS for the inline diff.
  $output['#attached']['css'][] = drupal_get_path('module', 'system') . '/css/system.diff.css';
  $diff = config_diff($this->targetStorage, $this->sourceStorage, $config_file);
  $formatter = new \DrupalDiffFormatter();
  $formatter->show_header = FALSE;
  $variables = array(
    'header' => array(
      array(
        'data' => t('Old'),
        'colspan' => '2',
      ),
      array(
        'data' => t('New'),
        'colspan' => '2',
      ),
    ),
    'rows' => $formatter
      ->format($diff),
  );
  $output['diff'] = array(
    '#markup' => theme('table', $variables),
  );
  $output['back'] = array(
    '#type' => 'link',
    '#attributes' => array(
      'class' => array(
        'dialog-cancel',
      ),
    ),
    '#title' => "Back to 'Synchronize configuration' page.",
    '#href' => 'admin/config/development/sync',
  );

  // @todo Remove use of drupal_set_title() when
  //   http://drupal.org/node/1871596 is in.
  drupal_set_title(t('View changes of @config_file', array(
    '@config_file' => $config_file,
  )), PASS_THROUGH);
  return $output;
}