You are here

protected function DiffLayoutBase::buildFilterNavigation in Diff 8

Build the filter navigation for the diff comparison.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

\Drupal\Core\Entity\ContentEntityInterface $left_revision: Revision from the left side.

\Drupal\Core\Entity\ContentEntityInterface $right_revision: Revision from the right side.

string $layout: The layout plugin selected.

string $active_filter: The active filter.

Return value

array The filter options.

2 calls to DiffLayoutBase::buildFilterNavigation()
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.

File

src/DiffLayoutBase.php, line 228

Class

DiffLayoutBase
Base class for diff layout plugins.

Namespace

Drupal\diff

Code

protected function buildFilterNavigation(ContentEntityInterface $entity, ContentEntityInterface $left_revision, ContentEntityInterface $right_revision, $layout, $active_filter) {

  // Build the view modes filter.
  $options['raw'] = [
    'title' => $this
      ->t('Raw'),
    'url' => PluginRevisionController::diffRoute($entity, $left_revision
      ->getRevisionId(), $right_revision
      ->getRevisionId(), $layout, [
      'filter' => 'raw',
    ]),
  ];
  $options['strip_tags'] = [
    'title' => $this
      ->t('Strip tags'),
    'url' => PluginRevisionController::diffRoute($entity, $left_revision
      ->getRevisionId(), $right_revision
      ->getRevisionId(), $layout, [
      'filter' => 'strip_tags',
    ]),
  ];
  $filter = $options[$active_filter];
  unset($options[$active_filter]);
  array_unshift($options, $filter);
  $build['options'] = [
    '#type' => 'operations',
    '#links' => $options,
  ];
  return $build;
}