You are here

public static function BackgroundBatchContext::processMessage in Background Process 7.2

2 calls to BackgroundBatchContext::processMessage()
BackgroundBatchContext::offsetSet in background_batch/background_batch.module
Override offsetSet(). Update progress if needed.
background_batch_overview_page in background_batch/background_batch.pages.inc
Overview of current and recent batch jobs.

File

background_batch/background_batch.module, line 345
This module adds background processing to Drupals batch API

Class

BackgroundBatchContext
Class batch context. Automatically updates progress when 'finished' index is changed.

Code

public static function processMessage($current_set, $finished = 0, $eta = 0) {
  $total = $current_set['total'];
  $count = $current_set['count'];
  $elapsed = $current_set['elapsed'];
  $start_time = $current_set['start'];
  $progress_message = $current_set['progress_message'];
  $current = $total - $count;
  $step = 1 / $total;
  $base = $current * $step;
  $progress = $base + $finished * $step;
  $time = microtime(TRUE);
  $elapsed = floor($time - $start_time);
  $values = array(
    '@remaining' => $count,
    '@total' => $total,
    '@current' => $current,
    '@percentage' => $progress * 100,
    '@elapsed' => format_interval($elapsed),
    // If possible, estimate remaining processing time.
    '@estimate' => format_interval(floor($eta) - floor($time)),
  );
  $message = strtr($progress_message, $values);
  return array(
    $progress,
    $message,
  );
}