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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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.