public ContentEntityBase::__set($name, $value)
Implements the magic method for setting object properties.
Uses default language always.
File
- core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 919
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\Entity
Code
public function __set($name, $value) { // Inline getFieldDefinition() to speed things up. if (!isset($this->fieldDefinitions)) { $this->getFieldDefinitions(); } // Handle Field API fields. if (isset($this->fieldDefinitions[$name])) { // Support setting values via property objects. if ($value instanceof TypedDataInterface) { $value = $value->getValue(); } // If a FieldItemList object already exists, set its value. if (isset($this->fields[$name][$this->activeLangcode])) { $this->fields[$name][$this->activeLangcode]->setValue($value); } // If not, create one. else { $this->getTranslatedField($name, $this->activeLangcode)->setValue($value); } } // The translations array is unset when cloning the entity object, we just // need to restore it. elseif ($name == 'translations') { $this->translations = $value; } // Directly write non-field values. else { $this->values[$name] = $value; } }
Please login to continue.