You are here

public function Drupal8::formatProperty in Realistic Dummy Content 8.2

Same name and namespace in other branches
  1. 7.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::formatProperty()
  2. 3.x api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::formatProperty()

File

api/src/Framework/Drupal8.php, line 256

Class

Drupal8
Drupal 8-specific code.

Namespace

Drupal\realistic_dummy_content_api\Framework

Code

public function formatProperty($type, $value, $options = array()) {
  switch ($type) {
    case 'file':
      return [
        'set' => $value
          ->id(),
        'options' => $options,
      ];
    case 'value':
    case 'tid':
    case 'text_with_summary':
      return [
        'set' => $value,
        'options' => $options,
      ];
    default:
      throw new \Exception('Unknown property type ' . $type);
  }
}