Same name and namespace in other branches
- 8.9.x core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::setValue()
- 9 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::setValue()
Sets the data value.
Parameters
mixed|null $value: The value to set in the format as documented for the data type or NULL to unset the data value.
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.
Throws
\InvalidArgumentException If the value input is inappropriate.
\Drupal\Core\TypedData\Exception\ReadOnlyException If the data is read-only.
Overrides TypedDataInterface::setValue
1 call to FieldItemBase::setValue()
- TextItemBase::applyDefaultValue in core/
modules/ text/ src/ Plugin/ Field/ FieldType/ TextItemBase.php - Applies the default value.
File
- core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php, line 118
Class
- FieldItemBase
- An entity field item.
Namespace
Drupal\Core\FieldCode
public function setValue($values, $notify = TRUE) {
// Treat the values as property value of the first property, if no array is
// given.
if (isset($values) && !is_array($values)) {
$keys = array_keys($this->definition
->getPropertyDefinitions());
$values = [
$keys[0] => $values,
];
}
parent::setValue($values, $notify);
}