You are here

function queue_ui_batch_test in Queue UI 7

Same name and namespace in other branches
  1. 6 queue_ui.module \queue_ui_batch_test()
  2. 7.2 queue_ui.module \queue_ui_batch_test()
1 string reference to 'queue_ui_batch_test'
queue_ui_queue_info in ./queue_ui.module

File

./queue_ui.module, line 151
queue_ui.module

Code

function queue_ui_batch_test($queue, &$context) {
  if (empty($context['sandbox'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['current'] = 0;
    $context['sandbox']['max'] = $queue
      ->numberOfItems();
  }
  for ($i = 0; $i < 20 && $context['sandbox']['current'] < $context['sandbox']['max']; $i++) {
    $item = $queue
      ->claimItem(20);

    // Lease time.
    if ($item) {

      // We would do some processing, if this were REAL.
      $queue
        ->deleteItem($item);
    }
    $context['sandbox']['progress']++;
    $context['sandbox']['current']++;
  }
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}