class MediaFeedsRemoteProvider in Media Feeds 7
Same name and namespace in other branches
- 7.2 includes/MediaFeedsRemoteProvider.inc \MediaFeedsRemoteProvider
Class for mapping values using the remote_stream_wrapper_module.
Hierarchy
- class \MediaFeedsProvider
- class \MediaFeedsRemoteProvider
Expanded class hierarchy of MediaFeedsRemoteProvider
File
- includes/
MediaFeedsRemoteProvider.inc, line 11 - Map files using the remote_stream_wrapper module.
View source
class MediaFeedsRemoteProvider extends MediaFeedsProvider {
protected $uri;
/**
* The value is the remote URI.
*/
public function __construct($value, $config = array()) {
$this->uri = file_stream_wrapper_uri_normalize($value);
}
/**
* Create a file object like remote_stream_wrapper_file_create_by_uri does,
* only don't save it directly.
*/
public function getFileObject() {
$file = new stdClass();
$file->fid = NULL;
$file->uri = $this->uri;
$file->filename = basename($file->uri);
$file->filemime = file_get_mimetype($file->uri);
$file->uid = $GLOBALS['user']->uid;
$file->status = FILE_STATUS_PERMANENT;
return $file;
}
/**
* Save the file or return an existing one.
*/
public function save() {
// Make sure no file with tha URI exists.
$existing = remote_stream_wrapper_file_load_by_uri($this->uri);
if ($existing) {
return $existing;
}
// Save the file.
$file = $this
->getFileObject();
file_save($file);
return $file;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaFeedsProvider:: |
protected | property | An associative array of configuration options. | |
MediaFeedsProvider:: |
protected | property | The target entity. | |
MediaFeedsProvider:: |
protected | property | The FeedsSource. | |
MediaFeedsProvider:: |
protected | property | The target name. | |
MediaFeedsProvider:: |
protected | property | The values to save. | |
MediaFeedsProvider:: |
public | function | Validate the source value. | 1 |
MediaFeedsRemoteProvider:: |
protected | property | ||
MediaFeedsRemoteProvider:: |
public | function |
Create a file object like remote_stream_wrapper_file_create_by_uri does,
only don't save it directly. Overrides MediaFeedsProvider:: |
|
MediaFeedsRemoteProvider:: |
public | function |
Save the file or return an existing one. Overrides MediaFeedsProvider:: |
|
MediaFeedsRemoteProvider:: |
public | function |
The value is the remote URI. Overrides MediaFeedsProvider:: |