You are here

protected function FeedsSource::startBackgroundJob in Feeds 8.2

Background job helper. Starts a background job using Job Scheduler.

Execute the first batch chunk of a background job on the current page load, moves the rest of the job processing to a cron powered background job.

Executing the first batch chunk is important, otherwise, when a user submits a source for import or clearing, we will leave her without any visual indicators of an ongoing job.

Parameters

$method: Method to execute on importer; one of 'import' or 'clear'.

Throws

Exception $e

See also

FeedsSource::startImport().

FeedsSource::startClear().

2 calls to FeedsSource::startBackgroundJob()
FeedsSource::startClear in lib/Drupal/feeds/FeedsSource.php
Start deleting all imported items of a source.
FeedsSource::startImport in lib/Drupal/feeds/FeedsSource.php
Start importing a source.

File

lib/Drupal/feeds/FeedsSource.php, line 609
Definition of FeedsSourceInterface and FeedsSource class.

Class

FeedsSource
This class encapsulates a source of a feed. It stores where the feed can be found and how to import it.

Namespace

Drupal\feeds

Code

protected function startBackgroundJob($method) {
  if (FEEDS_BATCH_COMPLETE != $this
    ->{$method}()) {
    $job = array(
      'type' => $this->id,
      'id' => $this->feed_nid,
      'period' => 0,
      'periodic' => FALSE,
    );
    JobScheduler::get("feeds_source_{$method}")
      ->set($job);
  }
}