You are here

public function FeedsSource::save in Feeds 8.2

Save configuration.

Overrides FeedsConfigurable::save

2 calls to FeedsSource::save()
FeedsSource::clear in lib/Drupal/feeds/FeedsSource.php
Remove all items from a feed.
FeedsSource::import in lib/Drupal/feeds/FeedsSource.php
Import a source: execute fetching, parsing and processing stage.

File

lib/Drupal/feeds/FeedsSource.php, line 419
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 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);
  }
}