protected function FileItemNormalizer::constructValue in Better Normalizers 8
Build the field item value using the incoming data.
Most normalizers that extend this class can simply use this method to construct the denormalized value without having to override denormalize() and reimplementing its validation logic or its call to set the field value.
It's recommended to not override this and instead provide a (de)normalizer at the DataType level.
Parameters
mixed $data: The incoming data for this field item.
array $context: The context passed into the Normalizer.
Return value
mixed The value to use in Entity::setValue().
Overrides EntityReferenceItemNormalizer::constructValue
File
- src/
Normalizer/ FileItemNormalizer.php, line 20
Class
- FileItemNormalizer
- Converts File items, including display and description values.
Namespace
Drupal\better_normalizers\NormalizerCode
protected function constructValue($data, $context) {
$value = parent::constructValue($data, $context);
if ($value) {
// Copy across any additional field-specific properties.
$value += $data;
unset($value['_links'], $value['uuid']);
}
return $value;
}