class MediaFeedsLibraryProvider in Media Feeds 7
Same name and namespace in other branches
- 7.2 includes/MediaFeedsLibraryProvider.inc \MediaFeedsLibraryProvider
Class for mapping values using existing files from the media library.
Hierarchy
- class \MediaFeedsProvider
- class \MediaFeedsLibraryProvider
Expanded class hierarchy of MediaFeedsLibraryProvider
File
- includes/
MediaFeedsLibraryProvider.inc, line 11 - Map existing files from the library.
View source
class MediaFeedsLibraryProvider extends MediaFeedsProvider {
protected $file;
public function __construct($value, $config = array()) {
// Query existing files.
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'file');
// By exact match or without file extension.
if (empty($config['no_file_extensions'])) {
$query
->propertyCondition('filename', $value);
}
else {
$query
->propertyCondition('filename', $value . '.', 'STARTS_WITH');
}
// Get the result.
$result = $query
->execute();
if (!empty($result)) {
$this->file = reset(file_load_multiple(array_keys($result['file'])));
}
}
public function getFileObject() {
return $this->file;
}
public function save() {
return $this->file;
}
public static function summaryCallback($mapping, $target, $form, $form_state) {
if (empty($mapping['no_file_extensions'])) {
return t('Source is <strong>exactly</strong> the filename');
}
else {
return t('Source <strong>doesn\'t have file extensions</strong>');
}
}
public static function formCallback($mapping, $target, $form, $form_state) {
return array(
'no_file_extensions' => array(
'#type' => 'checkbox',
'#title' => t('Source has no file extensions'),
'#default_value' => !empty($mapping['no_file_extensions']),
),
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaFeedsLibraryProvider:: |
protected | property | ||
MediaFeedsLibraryProvider:: |
public static | function | ||
MediaFeedsLibraryProvider:: |
public | function |
Create a file object from the source value. Overrides MediaFeedsProvider:: |
|
MediaFeedsLibraryProvider:: |
public | function |
Save the file in the database. Overrides MediaFeedsProvider:: |
|
MediaFeedsLibraryProvider:: |
public static | function | ||
MediaFeedsLibraryProvider:: |
public | function |
Constructor of MediaFeedsProvider. Overrides MediaFeedsProvider:: |
|
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 |