You are here

function views_bulk_operations_action_load_list in Views Bulk Operations (VBO) 7.3

The 'views_bulk_operations_action_views_load_list' action.

Parameters

$view: A string in the format "$view_name|$display_name".

$args: Arguments that should be passed to the View.

Return value

array Array containing the entity_list, an array of entity objects.

File

./views_bulk_operations.rules.inc, line 169
Views Bulk Operations conditions and actions for Rules.

Code

function views_bulk_operations_action_load_list($view, $args) {
  $vbo = _views_bulk_operations_rules_get_field($view, $args);

  // Get all entities, pass ids to the wrapper for lazy loading.
  $entity_type = $vbo
    ->get_entity_type();
  $entities = entity_metadata_wrapper("list<{$entity_type}>", array());
  foreach ($vbo->view->result as $row_index => $result) {

    // Grab the entire entity if it's already loaded or fall back to the
    // entity identifier.
    $entity = $vbo
      ->get_value($result);
    $data = $entity ? $entity : $result->{$vbo->real_field};
    $entities[] = entity_metadata_wrapper($entity_type, $data);
  }
  return array(
    'entity_list' => $entities,
  );
}