You are here

function activity_batch_regenerate_step in Activity 7

Same name and namespace in other branches
  1. 6.2 activity.admin.inc \activity_batch_regenerate_step()

Batch regeneration step.

Parameters

$aid: The actions.aid for this template.

$batch_context: An array representing the context for the batch operation.

2 string references to 'activity_batch_regenerate_step'
activity_batch_regenerate in ./activity.admin.inc
Set a batch process to regenerate activity for a specific hook and op pair.
activity_configure_handler_form_submit in ./activity.admin.inc
Form submit handler for the configuration form.

File

./activity.batch.inc, line 156
: Contains Batch API functions for long running processing.

Code

function activity_batch_regenerate_step($aid, &$batch_context) {
  $handler = activity_handler_batchable_load($aid);
  if (empty($handler)) {

    // Return error? Done?
  }
  $limit = 50;

  // Set up the sandbox for the regeneration.
  if (!isset($batch_context['sandbox']['progress'])) {
    $batch_context['sandbox']['progress'] = 0;
    $batch_context['sandbox']['last_eid'] = 0;
  }

  // Extracts $arguments and $total.
  extract($handler
    ->listEids($batch_context['sandbox']['progress'], $limit));
  foreach ($arguments as $eid => $arguments) {

    // Ensure they are there.
    $arguments += array(
      'argument1' => NULL,
      'argument2' => NULL,
    );
    activity_save_activity($handler, $eid, $arguments['argument1'], $arguments['argument2']);
    $batch_context['sandbox']['progress']++;
  }

  // Check if not finished.
  if ($batch_context['sandbox']['progress'] < $total) {
    $batch_context['finished'] = $batch_context['sandbox']['progress'] / $batch_context['sandbox']['max'];
  }
  else {

    // If finished, delete the sandbox.
    unset($batch_context['sandbox']);
  }
}