You are here

function acquia_lift_batch_finished in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift.batch.inc \acquia_lift_batch_finished()

Batch API callback for when processing of all items is complete.

Parameters

$success: Whether or not the batch completed successfully.

$results: An array holding the results of each operation.

$operations: An array of unprocessed operations.

1 string reference to 'acquia_lift_batch_finished'
acquia_lift_batch_sync_campaigns in ./acquia_lift.batch.inc
Batch syncs all campaigns to Lift.

File

./acquia_lift.batch.inc, line 92
acquia_lift.batch.inc

Code

function acquia_lift_batch_finished($success, $results, $operations) {
  if ($success) {

    // See if any of the results contains an error.
    $errors = array();
    foreach ($results as $result) {
      if (strpos($result, ACQUIA_LIFT_OPERATION_ERROR_PREFIX) === 0) {
        $errors[] = substr($result, strlen(ACQUIA_LIFT_OPERATION_ERROR_PREFIX));
      }
    }
    if (empty($errors)) {
      $message = t('Sync operation completed successfully.');
      $message_type = 'status';
    }
    else {
      $message_type = 'error';
      $message = t('Some errors occurred while syncing campaigns to Acquia Lift:');
      $message .= theme('item_list', array(
        'items' => $errors,
      ));
    }
    drupal_set_message($message, $message_type);
  }
  else {

    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    $message = t('An error occurred while processing %error_operation with arguments: @arguments', array(
      '%error_operation' => $error_operation[0],
      '@arguments' => print_r($error_operation[1], TRUE),
    ));
    drupal_set_message($message, 'error');
  }
}