1 batch_test.callbacks.inc _batch_test_finished_helper($batch_id, $success, $results, $operations)

Common 'finished' callbacks for batches 1 to 4.

File

core/modules/simpletest/tests/batch_test.callbacks.inc, line 79
Batch callbacks for the Batch API tests.

Code

function _batch_test_finished_helper($batch_id, $success, $results, $operations) {
  $messages = array("results for batch $batch_id");
  if ($results) {
    foreach ($results as $op => $op_results) {
      $messages[] = 'op ' . $op . ': processed ' . count($op_results) . ' elements';
    }
  }
  else {
    $messages[] = 'none';
  }

  if (!$success) {
    // A fatal error occurred during the processing.
    $error_operation = reset($operations);
    $messages[] = t('An error occurred while processing @op with arguments:<br/>@args', array('@op' => $error_operation[0], '@args' => print_r($error_operation[1], TRUE)));
  }

  backdrop_set_message(implode('<br />', $messages));
}