You are here

function views_bulk_operations_get_operation in Views Bulk Operations (VBO) 7.3

Returns an operation instance.

Parameters

$operation_id: The id of the operation to instantiate. For example: action::node_publish_action.

$entity_type: The entity type on which the operation operates.

$options: Options for this operation (label, operation settings, etc.)

6 calls to views_bulk_operations_get_operation()
views_bulk_operations_drush_execute in ./views_bulk_operations.drush.inc
Implementation of 'vbo execute' command.
views_bulk_operations_form_submit in ./views_bulk_operations.module
Submit handler for all steps of the VBO multistep form.
views_bulk_operations_get_applicable_operations in ./views_bulk_operations.module
Get all operations that match the current entity type.
views_bulk_operations_handler_field_operations::get_selected_operations in views/views_bulk_operations_handler_field_operations.inc
views_bulk_operations_handler_field_operations::options_submit in views/views_bulk_operations_handler_field_operations.inc
Performs some cleanup tasks on the options array before saving it.

... See full list

File

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

Code

function views_bulk_operations_get_operation($operation_id, $entity_type, $options) {
  $operations =& drupal_static(__FUNCTION__);

  // Create a unique hash of the options.
  $cid = md5(serialize($options));

  // See if there's a cached copy of the operation, including entity type and
  // options.
  if (!isset($operations[$operation_id][$entity_type][$cid])) {

    // Intentionally not using views_bulk_operations_get_operation_info() here
    // since it's an expensive function that loads all the operations on the
    // system, despite the fact that we might only need a few.
    $id_fragments = explode('::', $operation_id);
    $plugin = views_bulk_operations_get_operation_type($id_fragments[0]);
    $operation_info = $plugin['list callback']($operation_id);
    if ($operation_info) {
      $operations[$operation_id][$entity_type][$cid] = new $plugin['handler']['class']($operation_id, $entity_type, $operation_info, $options);
    }
    else {
      $operations[$operation_id][$entity_type][$cid] = FALSE;
    }
  }
  return $operations[$operation_id][$entity_type][$cid];
}