You are here

function RealisticDummyContentTextWithSummaryField::ValueFromFile_ in Realistic Dummy Content 7

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

$file: An object of type RealisticDummyContentFileGroup.

Return value

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

Throws

Exception.

Overrides RealisticDummyContentAttribute::ValueFromFile_

File

api/includes/RealisticDummyContentTextWithSummaryField.inc, line 17
Define RealisticDummyContentTextWithSummaryField autoload class.

Class

RealisticDummyContentTextWithSummaryField
Represents the text with summary field, which must have a text format when part of an entity object. Node body is one example.

Code

function ValueFromFile_($file) {
  $value = $file
    ->Value();

  // @TODO use the site's default, not filtered_html, as the default format.
  $format = $file
    ->Attribute('format', 'filtered_html');

  // If the value cannot be determined, which is different from an empty string.
  if ($value === NULL) {
    return NULL;
  }
  if ($value) {
    return array(
      LANGUAGE_NONE => array(
        array(
          'value' => $value,
          'format' => $format,
        ),
      ),
    );
  }
  else {
    return array();
  }
}