You are here

function Attribute::ValueFromFile in Realistic Dummy Content 8

Given a FileGroup object, get structured property if extentions ok.

The structured property can then be added to the entity.

For example, sometimes the appropriate property is array('value' => 'abc', 'text_format' => 'filtered_html'); other times is it just a string. Subclasses will determine what to do with the contents from the file.

Parameters

$file: The actual file object.

Return value

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 Attribute::ValueFromFile()
Attribute::ValueFromFiles in api/src/attributes/Attribute.php
Given a list of files, return a value from one of them.

File

api/src/attributes/Attribute.php, line 217
Define autoload class.

Class

Attribute
Represents either a field or a property for an entity.

Namespace

Drupal\realistic_dummy_content_api\attributes

Code

function ValueFromFile($file) {
  try {
    if (in_array($file
      ->GetRadicalExtension(), $this
      ->GetExtensions())) {
      return $this
        ->ValueFromFile_($file);
    }
  } catch (\Exception $e) {
    return NULL;
  }
}