function RealisticDummyContentAttribute::ValueFromFiles in Realistic Dummy Content 7
Given a list of files, return a value from one of them.
Parameters
$files: An array of file objects
Return value
A file object or array, or an associative array with the keys "value" and "format", or NULL if there are no files to choose from or the files have the wrong extension.
1 call to RealisticDummyContentAttribute::ValueFromFiles()
- RealisticDummyContentAttribute::ChangeFromFiles in api/
includes/ RealisticDummyContentAttribute.inc - Given candidate files, change the value of this attribute based on one of them.
File
- api/
includes/ RealisticDummyContentAttribute.inc, line 237 - Define RealisticDummyContentAttribute autoload class.
Class
- RealisticDummyContentAttribute
- Represents either a field or a property for an entity.
Code
function ValueFromFiles($files) {
try {
if (count($files)) {
$rand_index = $this
->rand(0, count($files) - 1);
$file = $files[$rand_index];
return $this
->ValueFromFile($file);
}
} catch (Exception $e) {
return NULL;
}
}