public function Drupal8::formatProperty in Realistic Dummy Content 3.x
Same name and namespace in other branches
- 8.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::formatProperty()
- 7.2 api/src/Framework/Drupal8.php \Drupal\realistic_dummy_content_api\Framework\Drupal8::formatProperty()
Formats a property to add it to an entity.
In Drupal8 it is just the file id, or value.
Parameters
string $type: Can be 'file', 'value', ...
mixed $value: A file, or string...
array $options: Extra options such as the format.
Return value
array The file data formatted for placement in an entity.
Overrides Framework::formatProperty
File
- api/
src/ Framework/ Drupal8.php, line 257
Class
- Drupal8
- Drupal 8-specific code.
Namespace
Drupal\realistic_dummy_content_api\FrameworkCode
public function formatProperty($type, $value, array $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);
}
}