public function MediaFeedsLibraryProvider::__construct in Media Feeds 7
Same name and namespace in other branches
- 7.2 includes/MediaFeedsLibraryProvider.inc \MediaFeedsLibraryProvider::__construct()
Constructor of MediaFeedsProvider.
Parameters
$value: The value to save.
$config: An associative array of configuration options.
Overrides MediaFeedsProvider::__construct
File
- includes/
MediaFeedsLibraryProvider.inc, line 14 - Map existing files from the library.
Class
- MediaFeedsLibraryProvider
- Class for mapping values using existing files from the media library.
Code
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'])));
}
}