$count = 1;
foreach ($all_associated_revisions as $entity_type_id =>
$associated_revisions) { $associated_entity_storage =
$this->entityTypeManager->
getStorage($entity_type_id);
// Sort the associated revisions in reverse ID order, so we can delete the
// most recent revisions first.
krsort($associated_revisions);
// Get a list of default revisions tracked by the given workspace, because
// they need to be handled differently than pending revisions.
$initial_revision_ids =
$this->workspaceAssociation->
getAssociatedInitialRevisions($workspace_id,
$entity_type_id);
foreach (array_keys($associated_revisions) as $revision_id) { if ($count >
$batch_size) { continue 2;
} // If the workspace is tracking the entity's default revision (i.e. the
// entity was created inside that workspace), we need to delete the
// whole entity after all of its pending revisions are gone.
if (isset($initial_revision_ids[$revision_id])) { $associated_entity_storage->
delete([$associated_entity_storage->
load($initial_revision_ids[$revision_id])]);
}