You are here

function _cacheflush_ui_mass_update_batch_process in CacheFlush 7.3

Executes a batch operation for cacheflush_ui_mass_update().

Parameters

array $presets: An array of presets IDs.

array $updates: Associative array of updates.

array $context: An array of contextual key/values.

1 string reference to '_cacheflush_ui_mass_update_batch_process'
cacheflush_ui_mass_update in modules/cacheflush_ui/includes/cacheflush_ui.class.inc
Make mass update of presets.

File

modules/cacheflush_ui/includes/cacheflush_ui.class.inc, line 363
Contains the CacheflushUIController class.

Code

function _cacheflush_ui_mass_update_batch_process(array $presets, array $updates, array &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($presets);
    $context['sandbox']['presets'] = $presets;
  }

  // Process presets by groups of 5.
  $count = min(5, count($context['sandbox']['presets']));
  for ($i = 1; $i <= $count; $i++) {

    // For each id, load the preset, reset the values, and save it.
    $id = array_shift($context['sandbox']['presets']);
    $presets = _cacheflush_ui_mass_update_helper($id, $updates);

    // Store result for post-processing in the finished callback.
    $context['results'][] = l($presets->title, 'cacheflush/' . $presets->id . '/view');

    // Update our progress information.
    $context['sandbox']['progress']++;
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}