You are here

public function WorkspaceMerger::getDifferringRevisionIdsOnSource in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/workspaces/src/WorkspaceMerger.php \Drupal\workspaces\WorkspaceMerger::getDifferringRevisionIdsOnSource()
  2. 10 core/modules/workspaces/src/WorkspaceMerger.php \Drupal\workspaces\WorkspaceMerger::getDifferringRevisionIdsOnSource()

Gets the revision identifiers for items which have changed on the source.

Return value

array A multidimensional array of revision identifiers, keyed by entity type IDs.

Overrides WorkspaceOperationInterface::getDifferringRevisionIdsOnSource

2 calls to WorkspaceMerger::getDifferringRevisionIdsOnSource()
WorkspaceMerger::getNumberOfChangesOnSource in core/modules/workspaces/src/WorkspaceMerger.php
Gets the total number of items which have changed on the source.
WorkspaceMerger::merge in core/modules/workspaces/src/WorkspaceMerger.php
Merges the contents of the source workspace into the target workspace.

File

core/modules/workspaces/src/WorkspaceMerger.php, line 172

Class

WorkspaceMerger
Default implementation of the workspace merger.

Namespace

Drupal\workspaces

Code

public function getDifferringRevisionIdsOnSource() {
  $source_revision_difference = [];
  $tracked_entities_on_source = $this->workspaceAssociation
    ->getTrackedEntities($this->sourceWorkspace
    ->id());
  $tracked_entities_on_target = $this->workspaceAssociation
    ->getTrackedEntities($this->targetWorkspace
    ->id());
  foreach ($tracked_entities_on_source as $entity_type_id => $tracked_revisions) {

    // Now we compare the revision IDs which are tracked by the source
    // workspace to those that are tracked by the target workspace, and the
    // difference between these two arrays gives us all the entities which
    // have a different revision ID on the source.
    if (!isset($tracked_entities_on_target[$entity_type_id])) {
      $source_revision_difference[$entity_type_id] = $tracked_revisions;
    }
    elseif ($revision_difference = array_diff_key($tracked_revisions, $tracked_entities_on_target[$entity_type_id])) {
      $source_revision_difference[$entity_type_id] = $revision_difference;
    }
  }
  return $source_revision_difference;
}