W3cubDocs

/Drupal 8

protected function FieldItemBase::writePropertyValue

protected FieldItemBase::writePropertyValue($property_name, $value)

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

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);
  }
  // Allow setting plain values for not-defined properties also.
  else {
    $this->values[$property_name] = $value;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldItemBase.php/function/FieldItemBase::writePropertyValue/8.1.x