You are here

public function RealisticDummyContentImageField::implementValueFromFile in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/includes/RealisticDummyContentImageField.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentImageField::implementValueFromFile()
  2. 3.x api/src/includes/RealisticDummyContentImageField.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentImageField::implementValueFromFile()

Given a RealisticDummyContentFileGroup object, get a structured property.

This function is not meant to called directly; rather, call ValueFromFile(). This function must be overriden by subclasses.

Parameters

object $file: An object of type RealisticDummyContentFileGroup.

Return value

null|array Returns structured data to be added to the entity object, or NULL if such data can't be creatd.

Throws

\Exception.

Overrides RealisticDummyContentAttribute::implementValueFromFile

File

api/src/includes/RealisticDummyContentImageField.php, line 22

Class

RealisticDummyContentImageField
Field modifier for image fields.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public function implementValueFromFile($file) {

  // Note that this is not called for the user picture in Drupal 7, which
  // does not use the field system.
  if (!$file
    ->value()) {
    return NULL;
  }
  $return = NULL;
  $file = $this
    ->imageSave($file);
  if ($file) {
    $return = Framework::instance()
      ->formatProperty('file', $file);
  }
  return $return;
}