function WorkspaceMerger::getDifferringRevisionIdsOnSource

Same name in other branches
  1. 8.9.x core/modules/workspaces/src/WorkspaceMerger.php \Drupal\workspaces\WorkspaceMerger::getDifferringRevisionIdsOnSource()
  2. 10 core/modules/workspaces/src/WorkspaceMerger.php \Drupal\workspaces\WorkspaceMerger::getDifferringRevisionIdsOnSource()
  3. 11.x core/modules/workspaces/src/WorkspaceMerger.php \Drupal\workspaces\WorkspaceMerger::getDifferringRevisionIdsOnSource()

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 174

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.