You are here

protected function FeedsSource::startBackgroundJob in Feeds 7.2

Background job helper. Starts a background job using the Drupal queue.

Parameters

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

See also

FeedsSource::startImport()

FeedsSource::startClear()

2 calls to FeedsSource::startBackgroundJob()
FeedsSource::startClear in includes/FeedsSource.inc
Start deleting all imported items of a source.
FeedsSource::startImport in includes/FeedsSource.inc
Start importing a source.

File

includes/FeedsSource.inc, line 1165
Definition of FeedsSourceInterface, FeedsState and FeedsSource class.

Class

FeedsSource
Holds the source of a feed to import.

Code

protected function startBackgroundJob($method) {
  $job = array(
    'type' => $this->id,
    'id' => $this->feed_nid,
  );
  $queue = DrupalQueue::get('feeds_source_' . $method);
  $queue
    ->createItem($job);
  switch ($method) {
    case 'import':
      $state = $this
        ->state(FEEDS_PARSE);
      break;
    case 'clear':
      $state = $this
        ->state(FEEDS_PROCESS_CLEAR);
      break;
    case 'expire':
      $state = $this
        ->state(FEEDS_PROCESS_EXPIRE);
      break;
  }
  if (isset($state)) {
    $state->progress = 0;
    $this
      ->save();
  }
}