You are here

public function FeedsSource::save in Feeds 7

Same name and namespace in other branches
  1. 6 includes/FeedsSource.inc \FeedsSource::save()
  2. 7.2 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() {

  // 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,
    'config' => $config,
    'source' => $source,
    'batch' => isset($this->batch) ? $this->batch : 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);
  }
}