public function FeedsFetcherResult::saveRawToFile in Feeds 7.2
Saves the raw fetcher result to a file.
Throws
RuntimeException In case the destination wasn't writable.
2 calls to FeedsFetcherResult::saveRawToFile()
- FeedsFetcherResult::getFilePath in plugins/
FeedsFetcher.inc - Get a path to a temporary file containing the resource provided by the fetcher.
- FeedsFetcherResult::__sleep in plugins/
FeedsFetcher.inc - Prevent saving the raw result when serializing object.
File
- plugins/
FeedsFetcher.inc, line 183 - Contains the FeedsFetcher and related classes.
Class
- FeedsFetcherResult
- Base class for all fetcher results.
Code
public function saveRawToFile() {
$file_in_progress_dir = $this
->getFeedsInProgressDir();
if (!file_prepare_directory($file_in_progress_dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS)) {
throw new RuntimeException(t('Feeds directory either cannot be created or is not writable.'));
}
$this->file_path = FALSE;
if ($file = file_save_data($this
->getRaw(), $this
->constructFilePath())) {
$file->status = 0;
file_save($file);
$this->file_path = $file->uri;
// Clear raw data to save memory, but also to prevent saving the same raw data
// to a file again in the same request.
$this->raw = NULL;
}
else {
throw new RuntimeException(t('Cannot write content to %dest', array(
'%dest' => $destination,
)));
}
}