diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php index 4656897..0ab9a60 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php @@ -131,7 +131,7 @@ public function loadMultiple(array $ids = NULL) { // Remove any invalid ids from the array. $passed_ids = array_intersect_key($passed_ids, $entities); foreach ($entities as $entity) { - $passed_ids[$entity->{$this->idKey}] = $entity; + $passed_ids[$entity->id()] = $entity; } $entities = $passed_ids; } @@ -310,11 +310,6 @@ public function save(EntityInterface $entity) { $entity->original = $this->loadUnchanged($id); } - // Build an ID if none is set. - if (!isset($entity->{$this->idKey})) { - $entity->{$this->idKey} = $entity->id(); - } - $entity->preSave($this); $this->invokeHook('presave', $entity); diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index d01563b..e314b83 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -86,7 +86,7 @@ function entity_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_new) $id = ConfigEntityStorage::getIDFromConfigName($id, $entity_type->getConfigPrefix()); $display = entity_load('entity_view_display', $id); $new_id = $entity_type_id . '.' . $bundle_new . '.' . $display->mode; - $display->id = $new_id; + $display->set('id', $new_id); $display->bundle = $bundle_new; $display->save(); } @@ -100,7 +100,7 @@ function entity_entity_bundle_rename($entity_type_id, $bundle_old, $bundle_new) $id = ConfigEntityStorage::getIDFromConfigName($id, $entity_type->getConfigPrefix()); $form_display = entity_load('entity_form_display', $id); $new_id = $entity_type_id . '.' . $bundle_new . '.' . $form_display->mode; - $form_display->id = $new_id; + $form_display->set('id', $new_id); $form_display->bundle = $bundle_new; $form_display->save(); } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 79a8b01..dd1bfa0 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -198,7 +198,6 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { */ public function toArray() { $names = array( - 'id', 'uuid', 'targetEntityType', 'bundle', @@ -208,7 +207,9 @@ public function toArray() { 'status', 'dependencies' ); - $properties = array(); + $properties = array( + 'id' => $this->id(), + ); foreach ($names as $name) { $properties[$name] = $this->get($name); } diff --git a/core/modules/field/field.module b/core/modules/field/field.module index 52f3996..db35e40 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -200,7 +200,7 @@ function field_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) { foreach ($instances as $instance) { if ($instance->entity_type == $entity_type && $instance->bundle == $bundle_old) { $id_new = $instance->entity_type . '.' . $bundle_new . '.' . $instance->field_name; - $instance->id = $id_new; + $instance->set('id', $id_new); $instance->bundle = $bundle_new; $instance->allowBundleRename(); $instance->save(); diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php index ff54ff4..11c4f0d 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldConfig.php @@ -239,7 +239,6 @@ public function id() { */ public function toArray() { $names = array( - 'id', 'uuid', 'status', 'langcode', @@ -254,7 +253,9 @@ public function toArray() { 'indexes', 'dependencies', ); - $properties = array(); + $properties = array( + 'id' => $this->id(), + ); foreach ($names as $name) { $properties[$name] = $this->get($name); } diff --git a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php index aa77ef8..3eea9cb 100644 --- a/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -283,7 +283,7 @@ public function __construct(array $values, $entity_type = 'field_instance_config * {@inheritdoc} */ public function id() { - return $this->entity_type . '.' . $this->bundle . '.' . $this->field->name; + return $this->entity_type . '.' . $this->bundle . '.' . $this->field_name; } /** @@ -291,7 +291,6 @@ public function id() { */ public function toArray() { $names = array( - 'id', 'uuid', 'status', 'langcode', @@ -307,7 +306,9 @@ public function toArray() { 'settings', 'dependencies', ); - $properties = array(); + $properties = array( + 'id' => $this->id(), + ); foreach ($names as $name) { $properties[$name] = $this->get($name); } diff --git a/core/modules/field/lib/Drupal/field/FieldConfigStorage.php b/core/modules/field/lib/Drupal/field/FieldConfigStorage.php index ba1803a..09fa119 100644 --- a/core/modules/field/lib/Drupal/field/FieldConfigStorage.php +++ b/core/modules/field/lib/Drupal/field/FieldConfigStorage.php @@ -135,7 +135,7 @@ public function loadByProperties(array $conditions = array()) { // When returning deleted fields, key the results by UUID since they can // include several fields with the same ID. - $key = $include_deleted ? $field->uuid : $field->id; + $key = $include_deleted ? $field->uuid() : $field->id(); $matching_fields[$key] = $field; } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php index d162cd3..edf1919 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php @@ -115,7 +115,8 @@ public function testDefaultImages() { ->save(); // Confirm the defaults are present on the article field settings form. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance->id/field"); + $instance_id = $instance->id(); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/field"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field']->id(), @@ -125,7 +126,7 @@ public function testDefaultImages() { ) ); // Confirm the defaults are present on the article field edit form. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance->id"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id"); $this->assertFieldByXpath( '//input[@name="instance[settings][default_image][fid][fids]"]', $default_images['instance']->id(), @@ -136,7 +137,7 @@ public function testDefaultImages() { ); // Confirm the defaults are present on the page field settings form. - $this->drupalGet("admin/structure/types/manage/page/fields/$instance->id/field"); + $this->drupalGet("admin/structure/types/manage/page/fields/$instance_id/field"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field']->id(), @@ -146,7 +147,8 @@ public function testDefaultImages() { ) ); // Confirm the defaults are present on the page field edit form. - $this->drupalGet("admin/structure/types/manage/page/fields/$instance2->id"); + $instance2_id = $instance2->id(); + $this->drupalGet("admin/structure/types/manage/page/fields/$instance2_id"); $this->assertFieldByXpath( '//input[@name="instance[settings][default_image][fid][fids]"]', $default_images['instance2']->id(), @@ -185,7 +187,7 @@ public function testDefaultImages() { $field->save(); // Confirm that the new default is used on the article field settings form. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance->id/field"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id/field"); $this->assertFieldByXpath( '//input[@name="field[settings][default_image][fid][fids]"]', $default_images['field_new']->id(), @@ -221,7 +223,7 @@ public function testDefaultImages() { // Confirm the new field instance default is used on the article field // admin form. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance->id"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id"); $this->assertFieldByXpath( '//input[@name="instance[settings][default_image][fid][fids]"]', $default_images['instance_new']->id(), @@ -259,7 +261,7 @@ public function testDefaultImages() { $instance->save(); // Confirm the article field instance default has been removed. - $this->drupalGet("admin/structure/types/manage/article/fields/$instance->id"); + $this->drupalGet("admin/structure/types/manage/article/fields/$instance_id"); $this->assertFieldByXpath( '//input[@name="instance[settings][default_image][fid][fids]"]', '', diff --git a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php index 985494c..e5783b7 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php +++ b/core/modules/rdf/lib/Drupal/rdf/Entity/RdfMapping.php @@ -138,14 +138,15 @@ public function id() { */ public function toArray() { $names = array( - 'id', 'uuid', 'targetEntityType', 'bundle', 'types', 'fieldMappings', ); - $properties = array(); + $properties = array( + 'id' => $this->id(), + ); foreach ($names as $name) { $properties[$name] = $this->get($name); }