function Attribute::ValueFromFiles in Realistic Dummy Content 8
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 Attribute::ValueFromFiles()
- Attribute::ChangeFromFiles in api/
src/ attributes/ Attribute.php - Given candidate files, change the value of this attribute based on one of them.
File
- api/
src/ attributes/ Attribute.php, line 257 - Define autoload class.
Class
- Attribute
- Represents either a field or a property for an entity.
Namespace
Drupal\realistic_dummy_content_api\attributesCode
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;
}
}