You are here

public function FeedsFileFetcher::sourceSave in Feeds 7.2

Same name and namespace in other branches
  1. 7 plugins/FeedsFileFetcher.inc \FeedsFileFetcher::sourceSave()

Overrides parent::sourceSave().

Overrides FeedsPlugin::sourceSave

File

plugins/FeedsFileFetcher.inc, line 177
Home of the FeedsFileFetcher and related classes.

Class

FeedsFileFetcher
Fetches data via HTTP.

Code

public function sourceSave(FeedsSource $source) {
  $source_config = $source
    ->getConfigFor($this);

  // If a new file is present, delete the old one and replace it with the new
  // one.
  if (isset($source_config['file'])) {
    $file = $source_config['file'];
    if (isset($source_config['fid'])) {
      $this
        ->deleteFile($source_config['fid'], $source->feed_nid);
    }
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
    file_usage_add($file, 'feeds', get_class($this), $source->feed_nid);
    $source_config['fid'] = $file->fid;
    unset($source_config['file']);
    $source
      ->setConfigFor($this, $source_config);
  }
}