diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index 99d17a5..b5aa1f4 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -657,7 +657,7 @@ protected function savePropertyData(EntityInterface $entity, $table_key = 'data_ /** * Maps from an entity object to the storage record. * - * @param \Drupal\Core\Entity\EntityInterface $entity + * @param \Drupal\Core\Entity\ContentEntityInterface $entity * The entity object. * @param string $table_key * (optional) The entity key identifying the target table. Defaults to @@ -666,10 +666,9 @@ protected function savePropertyData(EntityInterface $entity, $table_key = 'data_ * @return \stdClass * The record to store. */ - protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'base_table') { + protected function mapToStorageRecord(ContentEntityInterface $entity, $table_key = 'base_table') { $record = new \stdClass(); $values = array(); - $definitions = $entity->getPropertyDefinitions(); $schema = drupal_get_schema($this->entityType->get($table_key)); $is_new = $entity->isNew(); @@ -681,7 +680,13 @@ protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'bas $multi_column_fields[$field] = TRUE; continue; } - $values[$name] = isset($definitions[$name]) && isset($entity->$name->value) ? $entity->$name->value : NULL; + if ($entity->hasField($name)) { + $property = $entity->get($name)->first()->getMainPropertyName(); + $values[$name] = $entity->$name->$property; + } + else { + $values[$name] = NULL; + } } // Handle fields that store multiple properties and match each property name diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 3a776e2..2e47afe 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -123,30 +123,6 @@ public static function schema(FieldDefinitionInterface $field_definition) { /** * {@inheritdoc} */ - public function __get($name) { - $name = ($name == 'value') ? 'target_id' : $name; - return parent::__get($name); - } - - /** - * {@inheritdoc} - */ - public function get($property_name) { - $property_name = ($property_name == 'value') ? 'target_id' : $property_name; - return parent::get($property_name); - } - - /** - * {@inheritdoc} - */ - public function __isset($property_name) { - $property_name = ($property_name == 'value') ? 'target_id' : $property_name; - return parent::__isset($property_name); - } - - /** - * {@inheritdoc} - */ public function setValue($values, $notify = TRUE) { if (isset($values) && !is_array($values)) { // Directly update the property instead of invoking the parent, so it can