function WorkspacePublisher::getDifferringRevisionIdsOnTarget

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

Overrides WorkspaceOperationInterface::getDifferringRevisionIdsOnTarget

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

File

core/modules/workspaces/src/WorkspacePublisher.php, line 113

Class

WorkspacePublisher
Default implementation of the workspace publisher.

Namespace

Drupal\workspaces

Code

public function getDifferringRevisionIdsOnTarget() {
    $target_revision_difference = [];
    $tracked_entities = $this->workspaceAssociation
        ->getTrackedEntities($this->sourceWorkspace
        ->id());
    foreach ($tracked_entities as $entity_type_id => $tracked_revisions) {
        $entity_type = $this->entityTypeManager
            ->getDefinition($entity_type_id);
        // Get the latest revision IDs for all the entities that are tracked by
        // the source workspace.
        $query = $this->entityTypeManager
            ->getStorage($entity_type_id)
            ->getQuery()
            ->accessCheck(FALSE)
            ->condition($entity_type->getKey('id'), $tracked_revisions, 'IN')
            ->latestRevision();
        $result = $query->execute();
        // Now we compare the revision IDs which are tracked by the source
        // workspace to the latest revision IDs of those entities and the
        // difference between these two arrays gives us all the entities which
        // have been modified on the target.
        if ($revision_difference = array_diff_key($result, $tracked_revisions)) {
            $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.