public function FeedImportHandler::startCronImport in Feeds 8.3
Starts importing a feed via cron.
Parameters
\Drupal\feeds\FeedInterface $feed: The feed to queue.
Throws
\Drupal\feeds\Exception\LockException Thrown if a feed is locked.
File
- src/
FeedImportHandler.php, line 51
Class
- FeedImportHandler
- Runs the actual import on a feed.
Namespace
Drupal\feedsCode
public function startCronImport(FeedInterface $feed) {
if ($feed
->isLocked()) {
$args = [
'@id' => $feed
->bundle(),
'@fid' => $feed
->id(),
];
throw new LockException($this
->t('The feed @id / @fid is locked.', $args));
}
$this
->getExecutable(FeedsQueueExecutable::class)
->processItem($feed, FeedsQueueExecutable::BEGIN);
// Add timestamp to avoid queueing item more than once.
$feed
->setQueuedTime($this
->getRequestTime());
$feed
->save();
}