You are here

public function RealisticDummyContentAttribute::changeFromFiles 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::changeFromFiles()
  2. 3.x api/src/includes/RealisticDummyContentAttribute.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentAttribute::changeFromFiles()

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

Parameters

array $files: An array of files.

1 call to RealisticDummyContentAttribute::changeFromFiles()
RealisticDummyContentAttribute::change in api/src/includes/RealisticDummyContentAttribute.php
Changes this attribute by looking for data in files.

File

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

Class

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

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public 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();
  Framework::instance()
    ->setEntityProperty($entity, $this
    ->getName(), $value);
  $this
    ->getEntity()
    ->setEntity($entity);
}