You are here

public function FeedsSource::save in Feeds 7.2

Same name and namespace in other branches
  1. 6 includes/FeedsSource.inc \FeedsSource::save()
  2. 7 includes/FeedsSource.inc \FeedsSource::save()

Save configuration.

Overrides FeedsConfigurable::save

5 calls to FeedsSource::save()
FeedsSource::clear in includes/FeedsSource.inc
Remove all items from a feed.
FeedsSource::import in includes/FeedsSource.inc
Import a source: execute fetching, parsing and processing stage.
FeedsSource::pushImport in includes/FeedsSource.inc
Imports a fetcher result all at once in memory.
FeedsSource::startBackgroundJob in includes/FeedsSource.inc
Background job helper. Starts a background job using the Drupal queue.
FeedsSource::unlock in includes/FeedsSource.inc
Unlocks a feed.

File

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

Class

FeedsSource
Holds the source of a feed to import.

Code

public function save() {

  // Alert implementers of FeedsSourceInterface to the fact that we're saving.
  foreach ($this->importer->plugin_types as $type) {
    $this->importer->{$type}
      ->sourceSave($this);
  }
  $config = $this
    ->getConfig();

  // Store the source property of the fetcher in a separate column so that we
  // can do fast lookups on it.
  $source = '';
  if (isset($config[get_class($this->importer->fetcher)]['source'])) {
    $source = $config[get_class($this->importer->fetcher)]['source'];
  }
  $object = array(
    'id' => $this->id,
    'feed_nid' => $this->feed_nid,
    'imported' => $this->imported,
    'config' => $config,
    'source' => $source,
    'state' => isset($this->state) ? $this->state : FALSE,
    'fetcher_result' => isset($this->fetcher_result) ? $this->fetcher_result : FALSE,
  );
  if (db_query_range("SELECT 1 FROM {feeds_source} WHERE id = :id AND feed_nid = :nid", 0, 1, array(
    ':id' => $this->id,
    ':nid' => $this->feed_nid,
  ))
    ->fetchField()) {
    drupal_write_record('feeds_source', $object, array(
      'id',
      'feed_nid',
    ));
  }
  else {
    drupal_write_record('feeds_source', $object);
  }
}