You are here

protected function Map::writePropertyValue in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::writePropertyValue()
  2. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::writePropertyValue()

Writes the value of a property without handling changes.

Implementations of onChange() should use this method instead of set() in order to avoid onChange() being triggered again.

Parameters

string $property_name: The name of the property to be written.

$value: The value to set.

1 call to Map::writePropertyValue()
Map::set in core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php
Sets a property value.
1 method overrides Map::writePropertyValue()
FieldItemBase::writePropertyValue in core/lib/Drupal/Core/Field/FieldItemBase.php
Different to the parent Map class, we avoid creating property objects as far as possible in order to optimize performance. Thus we just update $this->values if no property object has been created yet.

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php, line 147

Class

Map
The "map" data type.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

protected function writePropertyValue($property_name, $value) {
  if ($this->definition
    ->getPropertyDefinition($property_name)) {
    $this
      ->get($property_name)
      ->setValue($value, FALSE);
  }
  else {

    // Just set the plain value, which allows adding a new entry to the map.
    $this->values[$property_name] = $value;
  }
}