protected function FeedsExecutable::finish in Feeds 8.3
Finalizes the import.
Parameters
\Drupal\feeds\FeedInterface $feed: The feed which import batch is about to be finished.
\Drupal\feeds\Result\FetcherResultInterface $fetcher_result: The last fetcher result.
Return value
bool True if the last batch was done. False if the import is still ongoing.
2 calls to FeedsExecutable::finish()
- FeedsBatchExecutable::finish in src/
FeedsBatchExecutable.php - Finalizes the import.
- FeedsExecutable::processItem in src/
FeedsExecutable.php - Processes a stage of an import.
1 method overrides FeedsExecutable::finish()
- FeedsBatchExecutable::finish in src/
FeedsBatchExecutable.php - Finalizes the import.
File
- src/
FeedsExecutable.php, line 304
Class
- FeedsExecutable
- Defines a feeds executable class.
Namespace
Drupal\feedsCode
protected function finish(FeedInterface $feed, FetcherResultInterface $fetcher_result) {
// Update item count.
$feed
->save();
if ($feed
->progressParsing() !== StateInterface::BATCH_COMPLETE) {
$this
->createBatch($feed, static::PARSE)
->addOperation(static::PARSE, [
'fetcher_result' => $fetcher_result,
])
->run();
return FALSE;
}
elseif ($feed
->progressFetching() !== StateInterface::BATCH_COMPLETE) {
$this
->createBatch($feed, static::FETCH)
->addOperation(static::FETCH)
->run();
return FALSE;
}
elseif ($feed
->progressCleaning() !== StateInterface::BATCH_COMPLETE) {
$clean_state = $feed
->getState(StateInterface::CLEAN);
$batch = $this
->createBatch($feed, static::CLEAN);
for ($i = 0; $i < $clean_state
->count(); $i++) {
$batch
->addOperation(static::CLEAN);
}
// Add a final item that finalizes the import.
$batch
->addOperation(static::FINISH, [
'fetcher_result' => $fetcher_result,
]);
$batch
->run();
return FALSE;
}
else {
$feed
->finishImport();
return TRUE;
}
}