You are here

function views_bulk_operations_enqueue_rows in Views Bulk Operations (VBO) 7.3

Divides the passed rows into groups and enqueues each group for processing

Parameters

$queue_name: The name of the queue.

$rows: The rows to be enqueued.

$operation: The object representing the current operation. Passed along with each new queue item.

$options: An array of options that affect execution (revision, entity_load_capacity). Passed along with each new queue item.

3 calls to views_bulk_operations_enqueue_rows()
views_bulk_operations_adjust_selection in ./views_bulk_operations.module
Batch API callback: loads the view page by page and enqueues all items.
views_bulk_operations_drush_execute in ./views_bulk_operations.drush.inc
Implementation of 'vbo execute' command.
views_bulk_operations_execute in ./views_bulk_operations.module
Entry point for executing the chosen operation upon selected rows.

File

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

Code

function views_bulk_operations_enqueue_rows($queue_name, $rows, $operation, $options) {
  global $user;
  $queue = DrupalQueue::get($queue_name, TRUE);
  $row_groups = array_chunk($rows, $options['entity_load_capacity'], TRUE);
  foreach ($row_groups as $row_group) {
    $entity_ids = array();
    foreach ($row_group as $row) {
      $entity_ids[] = $row['entity_id'];
    }
    $job = array(
      'title' => t('Perform %operation on @type !entity_ids.', array(
        '%operation' => $operation
          ->label(),
        '@type' => $operation->entityType,
        '!entity_ids' => implode(',', $entity_ids),
      )),
      'uid' => $user->uid,
      'arguments' => array(
        $row_group,
        $operation,
        $options,
      ),
    );
    $queue
      ->createItem($job);
  }
}