protected function DiffController::diffGenerator in Entity Share 8.3
Helper.
Parameters
string[] $left_entity: Array of lines of YAML file representing the local entity.
string[] $right_entity: Array of lines of YAML file representing the remote entity.
array $header: Header labels.
Return value
array A table render array.
1 call to DiffController::diffGenerator()
- DiffController::compareEntities in modules/
entity_share_diff/ src/ Controller/ DiffController.php - Returns a table showing the differences between local and remote entities.
File
- modules/
entity_share_diff/ src/ Controller/ DiffController.php, line 168
Class
- DiffController
- Returns responses for Diff support routes.
Namespace
Drupal\entity_share_diff\ControllerCode
protected function diffGenerator(array $left_entity, array $right_entity, array $header = []) {
$element = [];
$diff = new Diff($left_entity, $right_entity);
$this->diffFormatter->show_header = FALSE;
$this->diffFormatter->htmlOutput = TRUE;
$output = $this->diffFormatter
->format($diff);
// Add the CSS for the inline diff.
$element['#attached']['library'][] = 'system/diff';
$element['diff'] = [
'#type' => 'table',
'#attributes' => [
'class' => [
'diff',
],
],
'#header' => [
[
'data' => $header['left_label'],
'colspan' => '2',
],
[
'data' => $header['right_label'],
'colspan' => '2',
],
],
'#rows' => $output,
];
return $element;
}