You are here

public function State::progress in Feeds 8.3

Reports the progress of a batch.

When $total === $progress, the state of the task tracked by this state is regarded to be complete.

Should handle the following cases gracefully:

  • $total is 0.
  • $progress is larger than $total.
  • $progress approximates $total so that $finished rounds to 1.0.

Parameters

int $total: A number that is the total to be worked off.

int $progress: A number that is the progress made on $total.

Overrides StateInterface::progress

1 call to State::progress()
CleanState::progress in src/Feeds/State/CleanState.php
Reports the progress of a batch.
1 method overrides State::progress()
CleanState::progress in src/Feeds/State/CleanState.php
Reports the progress of a batch.

File

src/State.php, line 88

Class

State
Status of the import or clearing operation of a Feed.

Namespace

Drupal\feeds

Code

public function progress($total, $progress) {
  if ($progress > $total || $total === $progress) {
    $this
      ->setCompleted();
  }
  elseif ($total) {
    $this->progress = (double) ($progress / $total);
    if ($this->progress === StateInterface::BATCH_COMPLETE && $total !== $progress) {
      $this->progress = 0.99;
    }
  }
  else {
    $this
      ->setCompleted();
  }
}