You are here

public function WorkspaceMerger::getDifferringRevisionIdsOnTarget in Drupal 9

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

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

Return value

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

Overrides WorkspaceOperationInterface::getDifferringRevisionIdsOnTarget

1 call to WorkspaceMerger::getDifferringRevisionIdsOnTarget()
WorkspaceMerger::getNumberOfChangesOnTarget in core/modules/workspaces/src/WorkspaceMerger.php
Gets the total number of items which have changed on the target.

File

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

Class

WorkspaceMerger
Default implementation of the workspace merger.

Namespace

Drupal\workspaces

Code

public function getDifferringRevisionIdsOnTarget() {
  $target_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_target as $entity_type_id => $tracked_revisions) {

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