You are here

function revision_scheduler_entity_revision_load_multiple in Revision scheduler 7

Load multiple entity revisions.

Parameters

string $entity_type: An entity type.

int $entity_id: An entity ID to load.

array $revision_ids: An array of revision IDs to load.

Return value

array An array of entity revision objects from entity_load().

See also

entity_load()

3 calls to revision_scheduler_entity_revision_load_multiple()
revision_scheduler_edit_form in ./revision_scheduler.pages.inc
revision_scheduler_entity_revision_load in ./revision_scheduler.module
Load a single entity with an optional revision ID.
revision_scheduler_list_page in ./revision_scheduler.pages.inc
1 string reference to 'revision_scheduler_entity_revision_load_multiple'
revision_scheduler_entity_update in ./revision_scheduler.module
Implements hook_entity_update().

File

./revision_scheduler.module, line 311

Code

function revision_scheduler_entity_revision_load_multiple($entity_type, $entity_id, array $revision_ids) {
  $revisions =& drupal_static(__FUNCTION__, array());
  if (!isset($revisions[$entity_type . ':' . $entity_id])) {
    $revisions[$entity_type . ':' . $entity_id] = array();
  }
  $entity_revisions =& $revisions[$entity_type . ':' . $entity_id];
  if ($revision_ids_to_load = array_diff($revision_ids, array_keys($entity_revisions))) {
    $revision_key = revision_scheduler_get_entity_revision_key($entity_type);
    foreach ($revision_ids_to_load as $revision_id) {
      if ($entities = entity_load($entity_type, array(
        $entity_id,
      ), array(
        $revision_key => $revision_id,
      ))) {
        $entity_revisions[$revision_id] = reset($entities);
      }
    }
  }
  return array_intersect_key($entity_revisions, array_flip($revision_ids));
}