You are here

public function BackgroundProcess::setProgress in Background Process 7.2

Set progress

File

./background_process.inc, line 799
External API short overview

Class

BackgroundProcess
@file

Code

public function setProgress($progress, $progress_message = NULL) {
  $this
    ->ensureProcess();
  $this->progress = $fields['progress'] = $progress;
  if (isset($progress_message)) {
    $this->progress_message = $fields['progress_message'] = $progress_message;
  }

  // Don't spam the DB if someone decides to set the progress very rapidly.
  $time = microtime(TRUE);
  if ($progress < 1 && $this->progress_last_updated + $this->progress_interval > $time) {
    return $this;
  }
  $this->progress_last_updated = $time;
  db_update('background_process', array(
    'target' => 'background_process',
  ))
    ->fields($fields)
    ->condition('pid', $this->pid)
    ->execute();
  $this
    ->sendMessage('setProgress');
  return $this;
}