function Map::setValue
Same name in other branches
- 9 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()
- 11.x 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.
Overrides TypedData::setValue
1 call to Map::setValue()
- FieldItemBase::setValue in core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php - Overrides \Drupal\Core\TypedData\TypedData::setValue().
1 method overrides Map::setValue()
- FieldItemBase::setValue in core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php - Overrides \Drupal\Core\TypedData\TypedData::setValue().
File
-
core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ Map.php, line 74
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);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.