You are here

public function RealisticDummyContentAttribute::valueFromFile in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/includes/RealisticDummyContentAttribute.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentAttribute::valueFromFile()
  2. 3.x 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.


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.


api/src/includes/RealisticDummyContentAttribute.php, line 203


Represents either a field or a property for an entity.




public function valueFromFile($file) {
  try {
    if (in_array($file
      ->getRadicalExtension(), $this
      ->getExtensions())) {
      return $this
  } catch (Exception $e) {
    return NULL;