public function PriceModifiedItem::setValue in Price 3.0.x
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldType/PriceModifiedItem.php \Drupal\price\Plugin\Field\FieldType\PriceModifiedItem::setValue()
- 3.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.
bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.
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);
}