public function RealisticDummyContentAttribute::valueFromFile in Realistic Dummy Content 3.x
Same name and namespace in other branches
- 8.2 api/src/includes/RealisticDummyContentAttribute.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentAttribute::valueFromFile()
- 7.2 api/src/includes/RealisticDummyContentAttribute.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentAttribute::valueFromFile()
Given a RealisticDummyContentFileGroup object, get structured property.
The structured property can then be added to the entity.
For example, sometimes the appropriate property is array('value' => 'abc', 'text_format' => Framework::instance()->filteredHtml()); other times is it just a string. Subclasses will determine what to do with the contents from the file.
Parameters
object $file: The actual file object.
Return value
null|array In case of an error or if the value does not apply or is empty, return NULL; otherwise returns structured data to be added to the entity object.
1 call to RealisticDummyContentAttribute::valueFromFile()
- RealisticDummyContentAttribute::valueFromFiles in api/
src/ includes/ RealisticDummyContentAttribute.php - Given a list of files, return a value from one of them.
File
- api/
src/ includes/ RealisticDummyContentAttribute.php, line 207
Class
- RealisticDummyContentAttribute
- Represents either a field or a property for an entity.
Namespace
Drupal\realistic_dummy_content_api\includesCode
public function valueFromFile($file) {
try {
if (in_array($file
->getRadicalExtension(), $this
->getExtensions())) {
return $this
->implementValueFromFile($file);
}
return NULL;
} catch (\Throwable $e) {
return NULL;
}
}