You are here

function Attribute::ChangeFromFiles in Realistic Dummy Content 8

Given candidate files, change the value of this attribute based on one of them.

Parameters

$files: An array of files.

1 call to Attribute::ChangeFromFiles()
Attribute::Change in api/src/attributes/Attribute.php
Changes this attribute by looking for data in files.

File

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

Class

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

Namespace

Drupal\realistic_dummy_content_api\attributes

Code

function ChangeFromFiles($files) {
  $value = $this
    ->ValueFromFiles($files);
  if ($value === NULL) {

    // NULL indicates we could not find a value with which to replace the
    // current value. The value can still be '', or FALSE, etc.
    return;
  }
  $entity = $this
    ->GetEntity()
    ->GetEntity();
  $entity->{$this
    ->GetName()} = $value;
  $this
    ->GetEntity()
    ->SetEntity($entity);
}