diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php index 6fd8a54..7a80e8d 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageControllerNG.php @@ -240,8 +240,7 @@ protected function attachPropertyData(array &$entities, $load_revision = FALSE) foreach ($field_definition as $name => $definition) { // Set translatable properties only. if (isset($data_fields[$name]) && !empty($definition['translatable'])) { - $key_name = key($translation->{$name}->offsetGet(0)->getProperties()); - $translation->{$name}->{$key_name} = $values[$name]; + $translation->{$name}->value = $values[$name]; } // Avoid initializing configurable fields before loading them. elseif (!empty($definition['configurable'])) { @@ -420,8 +419,7 @@ protected function invokeHook($hook, EntityInterface $entity) { protected function mapToStorageRecord(EntityInterface $entity) { $record = new \stdClass(); foreach ($this->entityInfo['schema_fields_sql']['base_table'] as $name) { - $key = key($entity->$name->offsetGet(0)->getProperties()); - $record->$name = $entity->$name->{$key}; + $record->$name = $entity->$name->value; } return $record; } diff --git a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php index 76f4d2c..1b9f53e 100644 --- a/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php @@ -7,8 +7,7 @@ namespace Drupal\Core\Entity\Field\Type; -use Drupal\Core\Entity\Field\FieldItemBase; -use Drupal\Core\TypedData\ContextAwareInterface; +use \Drupal\Core\Entity\Field\FieldItemBase; /** * Defines the 'entity_reference' entity field item. @@ -28,7 +27,7 @@ class EntityReferenceItem extends FieldItemBase { static $propertyDefinitions; /** - * Implements Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). + * Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). */ public function getPropertyDefinitions() { // Definitions vary by entity type, so key them by entity type. @@ -57,7 +56,7 @@ public function getPropertyDefinitions() { } /** - * Overrides Drupal\Core\Entity\Field\FieldItemBase::setValue(). + * Overrides \Drupal\Core\Entity\Field\FieldItemBase::setValue(). */ public function setValue($values) { // Treat the values as property value of the entity field, if no array @@ -82,4 +81,12 @@ public function setValue($values) { throw new \InvalidArgumentException('Property ' . key($values) . ' is unknown.'); } } + + /** + * Overrides \Drupal\Core\Entity\Field\FieldItemBase::get(). + */ + public function get($property_name) { + $property_name = ($property_name == 'value') ? 'target_id' : $property_name; + return parent::get($property_name); + } }