public function MeasurementItem::setValue in Physical Fields 8
Overrides \Drupal\Core\TypedData\TypedData::setValue().
Parameters
array|null $values: An array of property values.
Overrides FieldItemBase::setValue
File
- src/
Plugin/ Field/ FieldType/ MeasurementItem.php, line 95
Class
- MeasurementItem
- Plugin implementation of the 'physical_measurement' field type.
Namespace
Drupal\physical\Plugin\Field\FieldTypeCode
public function setValue($values, $notify = TRUE) {
// Allow callers to pass a Measurement value object as the field item value.
if ($values instanceof Measurement) {
$measurement = $values;
$values = [
'number' => $measurement
->getNumber(),
'unit' => $measurement
->getUnit(),
];
}
parent::setValue($values, $notify);
}