You are here

public function DiffLayoutBase::buildRevisionsData in Diff 8

Build the revision link for the compared revisions.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $left_revision: Left revision that is compared.

\Drupal\Core\Entity\ContentEntityInterface $right_revision: Right revision that is compared.

Return value

array Header link for a revision in the revision comparison display.

3 calls to DiffLayoutBase::buildRevisionsData()
SplitFieldsDiffLayout::build in src/Plugin/diff/Layout/SplitFieldsDiffLayout.php
Builds a diff comparison between two revisions.
UnifiedFieldsDiffLayout::build in src/Plugin/diff/Layout/UnifiedFieldsDiffLayout.php
Builds a diff comparison between two revisions.
VisualInlineDiffLayout::build in src/Plugin/diff/Layout/VisualInlineDiffLayout.php
Builds a diff comparison between two revisions.

File

src/DiffLayoutBase.php, line 131

Class

DiffLayoutBase
Base class for diff layout plugins.

Namespace

Drupal\diff

Code

public function buildRevisionsData(ContentEntityInterface $left_revision, ContentEntityInterface $right_revision) {
  $right_revision = $this
    ->buildRevisionData($right_revision);
  $right_revision['#prefix'] = '<div class="diff-revision__items-group">';
  $right_revision['#suffix'] = '</div>';
  $left_revision = $this
    ->buildRevisionData($left_revision);
  $left_revision['#prefix'] = '<div class="diff-revision__items-group">';
  $left_revision['#suffix'] = '</div>';

  // Show the revisions that are compared.
  return [
    'header' => [
      'diff_revisions' => [
        '#type' => 'item',
        '#title' => $this
          ->t('Comparing'),
        '#wrapper_attributes' => [
          'class' => 'diff-revision',
        ],
        'items' => [
          '#prefix' => '<div class="diff-revision__items">',
          '#suffix' => '</div>',
          'right_revision' => $right_revision,
          'left_revision' => $left_revision,
        ],
      ],
    ],
  ];
}