You are here

public static function PluginRevisionController::diffRoute in Diff 8

Creates an url object for diff.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to be compared.

int $left_revision_id: Revision id of the left revision.

int $right_revision_id: Revision id of the right revision.

string $layout: (optional) The filter/layout added to the route.

array $layout_options: (optional) The layout options provided by the selected layout.

Return value

\Drupal\Core\Url The URL object.

3 calls to PluginRevisionController::diffRoute()
DiffLayoutBase::buildFilterNavigation in src/DiffLayoutBase.php
Build the filter navigation for the diff comparison.
PluginRevisionController::buildLayoutNavigation in src/Controller/PluginRevisionController.php
Builds a navigation dropdown button between the layout plugins.
VisualInlineDiffLayout::build in src/Plugin/diff/Layout/VisualInlineDiffLayout.php
Builds a diff comparison between two revisions.

File

src/Controller/PluginRevisionController.php, line 302

Class

PluginRevisionController
Base class for controllers that return responses on entity revision routes.

Namespace

Drupal\diff\Controller

Code

public static function diffRoute(ContentEntityInterface $entity, $left_revision_id, $right_revision_id, $layout = NULL, array $layout_options = NULL) {
  $entity_type_id = $entity
    ->getEntityTypeId();

  // @todo Remove the diff.revisions_diff route so we avoid adding extra cases.
  if ($entity
    ->getEntityTypeId() == 'node') {
    $route_name = 'diff.revisions_diff';
  }
  else {
    $route_name = "entity.{$entity_type_id}.revisions_diff";
  }
  $route_parameters = [
    $entity_type_id => $entity
      ->id(),
    'left_revision' => $left_revision_id,
    'right_revision' => $right_revision_id,
  ];
  if ($layout) {
    $route_parameters['filter'] = $layout;
  }
  $options = [];
  if ($layout_options) {
    $options = [
      'query' => $layout_options,
    ];
  }
  return Url::fromRoute($route_name, $route_parameters, $options);
}