You are here

public function BackgroundBatchContext::offsetSet in Background Process 7.2

Same name and namespace in other branches
  1. 6 background_batch/background_batch.module \BackgroundBatchContext::offsetSet()
  2. 7 background_batch/background_batch.module \BackgroundBatchContext::offsetSet()

Override offsetSet(). Update progress if needed.

File

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

Class

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

Code

public function offsetSet($name, $value) {
  if ($name == 'finished' || ($name = 'message')) {
    if ($this
      ->getBatch() && $this
      ->getProcess()) {
      list($progress, $message) = self::processMessage($this->batch['sets'][$this->batch['current_set']], $value, $this->process
        ->calculateETA());
      $message .= $message && $this['message'] ? '<br/>' : '';
      $message .= $this['message'];
      if ($progress >= $this->process
        ->getProgress()) {
        $this->process
          ->setProgress($progress, $message ? $message : NULL);
      }
    }
  }
  return parent::offsetSet($name, $value);
}