You are here

public function FeedsSource::scheduleImport in Feeds 8.2

Schedule periodic or background import tasks.

1 call to FeedsSource::scheduleImport()
FeedsSource::schedule in lib/Drupal/feeds/FeedsSource.php
Schedule all periodic tasks for this source.

File

lib/Drupal/feeds/FeedsSource.php, line 168
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

public function scheduleImport() {

  // Check whether any fetcher is overriding the import period.
  $period = $this->importer->config['import_period'];
  $fetcher_period = $this->importer->fetcher
    ->importPeriod($this);
  if (is_numeric($fetcher_period)) {
    $period = $fetcher_period;
  }
  $period = $this
    ->progressImporting() === FEEDS_BATCH_COMPLETE ? $period : 0;
  $job = array(
    'type' => $this->id,
    'id' => $this->feed_nid,
    // Schedule as soon as possible if a batch is active.
    'period' => $period,
    'periodic' => TRUE,
  );
  if ($period == FEEDS_SCHEDULE_NEVER) {
    JobScheduler::get('feeds_source_import')
      ->remove($job);
  }
  else {
    JobScheduler::get('feeds_source_import')
      ->set($job);
  }
}