public function ContentController::diff in Content Synchronization 8
Same name and namespace in other branches
- 8.2 src/Controller/ContentController.php \Drupal\content_sync\Controller\ContentController::diff()
- 3.0.x src/Controller/ContentController.php \Drupal\content_sync\Controller\ContentController::diff()
Shows diff of specified content file.
Parameters
string $source_name: The name of the content file.
string $target_name: (optional) The name of the target content file if different from the $source_name.
string $collection: (optional) The content collection name. Defaults to the default collection.
Return value
string Table showing a two-way diff between the active and staged content.
1 string reference to 'ContentController::diff'
File
- src/
Controller/ ContentController.php, line 127
Class
- ContentController
- Returns responses for content module routes.
Namespace
Drupal\content_sync\ControllerCode
public function diff($source_name, $target_name = NULL, $collection = NULL) {
if (!isset($collection)) {
$collection = StorageInterface::DEFAULT_COLLECTION;
}
$diff = $this->contentManager
->diff($this->targetStorage, $this->sourceStorage, $source_name, $target_name, $collection);
$this->diffFormatter->show_header = FALSE;
$build = [];
$build['#title'] = t('View changes of @content_file', [
'@content_file' => $source_name,
]);
// Add the CSS for the inline diff.
$build['#attached']['library'][] = 'system/diff';
$build['diff'] = [
'#type' => 'table',
'#attributes' => [
'class' => [
'diff',
],
],
'#header' => [
[
'data' => t('Active'),
'colspan' => '2',
],
[
'data' => t('Staged'),
'colspan' => '2',
],
],
'#rows' => $this->diffFormatter
->format($diff),
];
$build['back'] = [
'#type' => 'link',
'#attributes' => [
'class' => [
'dialog-cancel',
],
],
'#title' => "Back to 'Synchronize content' page.",
'#url' => Url::fromRoute('content.sync'),
];
return $build;
}