You are here

function batch_example_batch_2 in Examples for Developers 6

Same name and namespace in other branches
  1. 7 batch_example/batch_example.module \batch_example_batch_2()

Batch 2 : load all nodes 5 by 5, 20 times (Multipart operation)

This method does not yet do the work; it simply builds an array of the work which needs to be done during the batch processing. The results of this function will be passed to the batch processor for actual processing.

Related topics

1 call to batch_example_batch_2()
batch_example_multistep_form_submit in batch_example/batch_example.module

File

batch_example/batch_example.module, line 214
This is an example outlining how a module can define batches.

Code

function batch_example_batch_2() {
  $operations = array();
  for ($i = 0; $i < 20; $i++) {
    $operations[] = array(
      'batch_example_op_2',
      array(),
    );
  }
  $batch = array(
    'operations' => $operations,
    'finished' => 'batch_example_finished',
    // We can define custom messages instead of the default ones.
    'title' => t('Processing batch 2'),
    'init_message' => t('Batch 2 is starting.'),
    'progress_message' => t('Processed @current out of @total.'),
    'error_message' => t('Batch 2 has encountered an error.'),
  );
  return $batch;
}