function Map::writePropertyValue

Same name in other branches
  1. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::writePropertyValue()
  2. 8.9.x core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::writePropertyValue()
  3. 10 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 149

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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.