You are here

protected function FieldItemBase::writePropertyValue in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::writePropertyValue()
  2. 9 core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::writePropertyValue()

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.

Overrides Map::writePropertyValue

3 calls to FieldItemBase::writePropertyValue()
EntityReferenceItem::onChange in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
React to changes to a child property or item.
LanguageItem::onChange in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
React to changes to a child property or item.
TextItemBase::onChange in core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php
React to changes to a child property or item.

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 121

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

protected function writePropertyValue($property_name, $value) {

  // For defined properties there is either a property object or a plain
  // value that needs to be updated.
  if (isset($this->properties[$property_name])) {
    $this->properties[$property_name]
      ->setValue($value, FALSE);
  }
  else {
    $this->values[$property_name] = $value;
  }
}