public function Feed::progressImporting in Feeds 8.3
Reports the progress of the import process.
Return value
float A float between 0 and 1. 1 = StateInterface::BATCH_COMPLETE.
Overrides FeedInterface::progressImporting
File
- src/
Entity/ Feed.php, line 432
Class
- Feed
- Defines the feed entity class.
Namespace
Drupal\feeds\EntityCode
public function progressImporting() {
$fetcher = $this
->getState(StateInterface::FETCH);
$parser = $this
->getState(StateInterface::PARSE);
if ($fetcher->progress === StateInterface::BATCH_COMPLETE && $parser->progress === StateInterface::BATCH_COMPLETE) {
return StateInterface::BATCH_COMPLETE;
}
// Fetching envelops parsing.
// @todo: this assumes all fetchers neatly use total. May not be the case.
$fetcher_fraction = $fetcher->total ? 1.0 / $fetcher->total : 1.0;
$parser_progress = $parser->progress * $fetcher_fraction;
$result = $fetcher->progress - $fetcher_fraction + $parser_progress;
if ($result >= StateInterface::BATCH_COMPLETE) {
return 0.99;
}
return $result;
}