You are here

public function ConfigEntityRevisionsDiffController::compareConfigEntityRevisions in Config Entity Revisions 8

Same name and namespace in other branches
  1. 1.x src/ConfigEntityRevisionsDiffController.php \Drupal\config_entity_revisions\ConfigEntityRevisionsDiffController::compareConfigEntityRevisions()

Returns a table which shows the differences between two entity revisions.

Parameters

string $config_entity_type: The type of entity to compare

mixed $config_entity_id: The ID of the entity.

int $left_revision: Id of the revision from the left.

int $right_revision: Id of the revision from the right.

string $filter: If $filter == 'raw' raw text is compared (including html tags) If $filter == 'raw-plain' markdown function is applied to the text before comparison.

Return value

array Table showing the diff between the two node revisions.

File

src/ConfigEntityRevisionsDiffController.php, line 63

Class

ConfigEntityRevisionsDiffController
Class ConfigEntityRevisionsDiffController.

Namespace

Drupal\config_entity_revisions

Code

public function compareConfigEntityRevisions($config_entity_type, $config_entity_id, $left_revision, $right_revision, $filter) {
  $entity_type = $this->entityTypeManager
    ->getDefinition($config_entity_type);
  $class = $entity_type
    ->get('class');
  if (!in_array('Drupal\\config_entity_revisions\\ConfigEntityRevisionsInterface', class_implements($class))) {
    return [];
  }
  $storage = $this->entityTypeManager
    ->getStorage($config_entity_type);
  $route_match = \Drupal::routeMatch();
  $left_revision = $storage
    ->loadRevision($left_revision);
  $right_revision = $storage
    ->loadRevision($right_revision);
  $build = $this
    ->compareEntityRevisions($route_match, $left_revision, $right_revision, $filter);
  return $build;
}