public function LiveRepositoryHandler::getDifferringRevisionIdsOnTarget in Workspace 8.2
Gets the revision identifiers for items which have changed on the target.
@todo Update the return values to be only UUIDs and revision UUIDs in https://www.drupal.org/node/2958752
Return value
array A multidimensional array of revision identifiers, either the revision ID or the revision UUID, keyed by entity type IDs.
Overrides RepositoryHandlerInterface::getDifferringRevisionIdsOnTarget
1 call to LiveRepositoryHandler::getDifferringRevisionIdsOnTarget()
- LiveRepositoryHandler::getNumberOfChangesOnTarget in src/
Plugin/ RepositoryHandler/ LiveRepositoryHandler.php - Gets the total number of items which have changed on the target.
File
- src/
Plugin/ RepositoryHandler/ LiveRepositoryHandler.php, line 165
Class
- LiveRepositoryHandler
- Defines a plugin which replicates content to the default (Live) workspace.
Namespace
Drupal\workspace\Plugin\RepositoryHandlerCode
public function getDifferringRevisionIdsOnTarget() {
$target_revision_difference = [];
$tracked_entities = $this->workspaceAssociationStorage
->getTrackedEntities($this->source);
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()
->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;
}