/** * {@inheritdoc} * * @todo Make parsers be able to handle streams. Maybe exclusively. * @todo Clean download cache directory. */ public function fetch(FeedInterface $feed) { $feed_config = $feed->getConfigurationFor($this); $response = $this->get($feed_config['source']); // 304, nothing to see here. if ($response->getStatusCode() == 304) { drupal_set_message($this->t('The feed has not been updated.')); return; } // If there was a redirect, the url will be updated automagically. if ($url = $response->getParams()->get('feeds.redirect')) { $feed_config['source'] = $url; $feed->setConfigFor($this, $feed_config); } $tempname = $response->getBody()->getUri(); $response->getBody()->close(); $download_file = $this->prepareDirectory($feed_config['source']); file_unmanaged_move($tempname, $download_file, FILE_EXISTS_REPLACE); return new FetcherResult($download_file); }