public function ContentEntityStorageBase::loadMultipleRevisions in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::loadMultipleRevisions()
Loads multiple entity revisions.
Parameters
array $revision_ids: An array of revision IDs to load.
Return value
\Drupal\Core\Entity\RevisionableInterface[] An array of entity revisions keyed by their revision ID, or an empty array if none found.
Overrides RevisionableStorageInterface::loadMultipleRevisions
1 call to ContentEntityStorageBase::loadMultipleRevisions()
- ContentEntityStorageBase::loadRevision in core/lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php 
- Load a specific entity revision.
1 method overrides ContentEntityStorageBase::loadMultipleRevisions()
- ContentEntityNullStorage::loadMultipleRevisions in core/lib/ Drupal/ Core/ Entity/ ContentEntityNullStorage.php 
- Loads multiple entity revisions.
File
- core/lib/ Drupal/ Core/ Entity/ ContentEntityStorageBase.php, line 548 
Class
- ContentEntityStorageBase
- Base class for content entity storage handlers.
Namespace
Drupal\Core\EntityCode
public function loadMultipleRevisions(array $revision_ids) {
  $revisions = $this
    ->doLoadMultipleRevisionsFieldItems($revision_ids);
  // The hooks are executed with an array of entities keyed by the entity ID.
  // As we could load multiple revisions for the same entity ID at once we
  // have to build groups of entities where the same entity ID is present only
  // once.
  $entity_groups = [];
  $entity_group_mapping = [];
  foreach ($revisions as $revision) {
    $entity_id = $revision
      ->id();
    $entity_group_key = isset($entity_group_mapping[$entity_id]) ? $entity_group_mapping[$entity_id] + 1 : 0;
    $entity_group_mapping[$entity_id] = $entity_group_key;
    $entity_groups[$entity_group_key][$entity_id] = $revision;
  }
  // Invoke the entity hooks for each group.
  foreach ($entity_groups as $entities) {
    $this
      ->invokeStorageLoadHook($entities);
    $this
      ->postLoad($entities);
  }
  // Ensure that the returned array is ordered the same as the original
  // $ids array if this was passed in and remove any invalid IDs.
  if ($revision_ids) {
    $flipped_ids = array_intersect_key(array_flip($revision_ids), $revisions);
    $revisions = array_replace($flipped_ids, $revisions);
  }
  return $revisions;
}