You are here

function _views_bulk_operations_entity_load in Views Bulk Operations (VBO) 7.3

Loads multiple entities by their entity or revision ids, and returns them, keyed by the id used for loading.

3 calls to _views_bulk_operations_entity_load()
theme_views_bulk_operations_confirmation in ./views_bulk_operations.module
Theme function to show the confirmation page before executing the operation.
views_bulk_operations_direct_process in ./views_bulk_operations.module
Processes the passed rows directly (without batching and queueing).
views_bulk_operations_queue_item_process in ./views_bulk_operations.module
Processes the provided queue item.

File

./views_bulk_operations.module, line 1323
Allows operations to be performed on items selected in a view.

Code

function _views_bulk_operations_entity_load($entity_type, $ids, $revision = FALSE) {
  if (!$revision) {
    $entities = entity_load($entity_type, $ids);
  }
  else {

    // D7 can't load multiple entities by revision_id. Lovely.
    $info = entity_get_info($entity_type);
    $entities = array();
    foreach ($ids as $revision_id) {
      $loaded_entities = entity_load($entity_type, array(), array(
        $info['entity keys']['revision'] => $revision_id,
      ));
      $entities[$revision_id] = reset($loaded_entities);
    }
  }
  return $entities;
}