/**
* Acts on entity IDs before they are loaded.
*
* @see hook_entity_preload()
*/
public function entityPreload(array
$ids,
$entity_type_id) { $entities =
[];
// Only run if the entity type can belong to a workspace and we are in a
// non-default workspace.
if (!
$this->workspaceManager->
shouldAlterOperations($this->entityTypeManager->
getDefinition($entity_type_id))) { return $entities;
} // Get a list of revision IDs for entities that have a revision set for the
// current active workspace. If an entity has multiple revisions set for a
// workspace, only the one with the highest ID is returned.
if ($tracked_entities =
$this->workspaceAssociation->
getTrackedEntities($this->workspaceManager->
getActiveWorkspace()->
id(),
$entity_type_id,
$ids)) { /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
$storage =
$this->entityTypeManager->
getStorage($entity_type_id);
// Swap out every entity which has a revision set for the current active