You are here

public function FeedsSource::save in Feeds 6

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

Save configuration.

Overrides FeedsConfigurable::save

2 calls to FeedsSource::save()
FeedsSource::clear in includes/FeedsSource.inc
Remove all items from a feed.
FeedsSource::import in includes/FeedsSource.inc
Import a feed: execute fetching, parsing and processing stage.

File

includes/FeedsSource.inc, line 225
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.

Code

public function save() {
  $config = $this
    ->getConfig();

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

  // 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,
    'config' => $config,
    'source' => $source,
    'batch' => isset($this->batch) ? $this->batch : FALSE,
  );
  if (db_result(db_query_range("SELECT 1 FROM {feeds_source} WHERE id = '%s' AND feed_nid = %d", $this->id, $this->feed_nid, 0, 1))) {
    drupal_write_record('feeds_source', $object, array(
      'id',
      'feed_nid',
    ));
  }
  else {
    drupal_write_record('feeds_source', $object);
  }
}