public function StateItem::setValue in State Machine 8
Overrides \Drupal\Core\TypedData\TypedData::setValue().
Parameters
array|null $values: An array of property values.
Overrides FieldItemBase::setValue
2 calls to StateItem::setValue()
- StateItem::applyDefaultValue in src/
Plugin/ Field/ FieldType/ StateItem.php - Applies the default value.
- StateItem::applyTransition in src/
Plugin/ Field/ FieldType/ StateItem.php - Applies the given transition, changing the current state.
File
- src/
Plugin/ Field/ FieldType/ StateItem.php, line 143
Class
- StateItem
- Plugin implementation of the 'state' field type.
Namespace
Drupal\state_machine\Plugin\Field\FieldTypeCode
public function setValue($values, $notify = TRUE) {
if (empty($this->originalValue)) {
// If no array is given, then the method received just the state value.
if (isset($values) && !is_array($values)) {
$values = [
'value' => $values,
];
}
// Track the original field value to allow isValid() to validate changes
// and to react to transitions.
$this->originalValue = $values['value'];
}
parent::setValue($values, $notify);
}