public function PriceModifiedItem::setValue in Price 8
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldType/PriceModifiedItem.php \Drupal\price\Plugin\Field\FieldType\PriceModifiedItem::setValue()
- 3.0.x src/Plugin/Field/FieldType/PriceModifiedItem.php \Drupal\price\Plugin\Field\FieldType\PriceModifiedItem::setValue()
Overrides \Drupal\Core\TypedData\TypedData::setValue().
Parameters
array|null $values: An array of property values.
Overrides PriceItem::setValue
File
- src/
Plugin/ Field/ FieldType/ PriceModifiedItem.php, line 112
Class
- PriceModifiedItem
- Plugin implementation of the 'modified price' field type.
Namespace
Drupal\price\Plugin\Field\FieldTypeCode
public function setValue($values, $notify = TRUE) {
// Allow callers to pass a Price value object as the field item value.
if ($values instanceof PriceModified) {
$price = $values;
$values = [
'number' => $price
->getNumber(),
'currency_code' => $price
->getCurrencyCode(),
'modifier' => $price
->getModifier(),
];
}
parent::setValue($values, $notify);
}