public function Map::setValue in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::setValue()
- 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::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 TypedData::setValue
1 call to Map::setValue()
- FieldItemBase::setValue in core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php - Sets the data value.
1 method overrides Map::setValue()
- FieldItemBase::setValue in core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php - Sets the data value.
File
- core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ Map.php, line 78
Class
- Map
- The "map" data type.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function setValue($values, $notify = TRUE) {
if (isset($values) && !is_array($values)) {
throw new \InvalidArgumentException("Invalid values given. Values must be represented as an associative array.");
}
$this->values = $values;
// Update any existing property objects.
foreach ($this->properties as $name => $property) {
$value = isset($values[$name]) ? $values[$name] : NULL;
$property
->setValue($value, FALSE);
// Remove the value from $this->values to ensure it does not contain any
// value for computed properties.
unset($this->values[$name]);
}
// Notify the parent of any changes.
if ($notify && isset($this->parent)) {
$this->parent
->onChange($this->name);
}
}