function WorkspaceMerger::getDifferringRevisionIdsOnTarget

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

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 162

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

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