Commit 18b755b2 authored by alexpott's avatar alexpott

Issue #2282627 by yched, swentel: Remove field_uuid from field instance config records.

parent bd9eef3f
......@@ -58,9 +58,6 @@ field.instance.*.*.*:
label:
type: label
label: 'Label'
field_uuid:
type: string
label: 'Field UUID'
field_name:
type: string
label: 'Field name'
......
......@@ -54,13 +54,6 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
*/
public $field_name;
/**
* The UUID of the field attached to the bundle by this instance.
*
* @var string
*/
public $field_uuid;
/**
* The name of the entity type the instance is attached to.
*
......@@ -193,7 +186,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
public $deleted = FALSE;
/**
* The field ConfigEntity object corresponding to $field_uuid.
* The field ConfigEntity object this is an instance of.
*
* @var \Drupal\field\Entity\FieldConfig
*/
......@@ -306,10 +299,7 @@ public function toArray() {
public function postCreate(EntityStorageInterface $storage) {
// Validate that we have a valid field for this instance. This throws an
// exception if the field is invalid.
$field = $this->getFieldStorageDefinition();
// Make sure the field_uuid is populated.
$this->field_uuid = $field->uuid();
$this->getFieldStorageDefinition();
// 'Label' defaults to the field name (mostly useful for field instances
// created in tests).
......@@ -346,7 +336,7 @@ public function preSave(EntityStorageInterface $storage) {
if ($this->bundle != $this->original->bundle && empty($this->bundle_rename_allowed)) {
throw new FieldException("Cannot change an existing instance's bundle.");
}
if ($this->field_uuid != $this->original->field_uuid) {
if ($field->uuid() != $this->original->getFieldStorageDefinition()->uuid()) {
throw new FieldException("Cannot change an existing instance's field.");
}
// Set the default instance settings.
......@@ -405,6 +395,7 @@ public static function preDelete(EntityStorageInterface $storage, array $instanc
if (!$instance->deleted) {
$config = $instance->toArray();
$config['deleted'] = TRUE;
$config['field_uuid'] = $instance->getFieldStorageDefinition()->uuid();
$deleted_instances[$instance->uuid()] = $config;
}
}
......@@ -440,7 +431,7 @@ public static function postDelete(EntityStorageInterface $storage, array $instan
$field = $instance->getFieldStorageDefinition();
if (!$instance->deleted && empty($instance->noFieldDelete) && !$instance->isUninstalling() && count($field->getBundles()) == 0) {
// Key by field UUID to avoid deleting the same field twice.
$fields_to_delete[$instance->field_uuid] = $field;
$fields_to_delete[$field->uuid()] = $field;
}
}
if ($fields_to_delete) {
......
......@@ -143,7 +143,8 @@ public function loadByProperties(array $conditions = array()) {
break;
case 'field_id':
$checked_value = $instance->field_uuid;
case 'field_uuid':
$checked_value = $field->uuid();
break;
case 'uuid';
......
id: entity_test.entity_test.field_test_import_staging
uuid: ea711065-6940-47cd-813d-618f64095481
langcode: und
field_uuid: 0bf654cc-f14a-4881-b94c-76959e47466b
field_name: field_test_import_staging
entity_type: entity_test
bundle: entity_test
......
id: entity_test.test_bundle.field_test_import_staging_2
uuid: f07794a2-d7cc-45b6-b40d-13cf021b5552
langcode: und
field_uuid: 2165d9aa-9a0c-41a1-be02-2a49f3405c00
field_name: field_test_import_staging_2
entity_type: entity_test
bundle: test_bundle
......
id: entity_test.test_bundle_2.field_test_import_staging_2
uuid: 49d6dd19-5097-443d-8f00-fc79525bebce
langcode: und
field_uuid: 2165d9aa-9a0c-41a1-be02-2a49f3405c00
field_name: field_test_import_staging_2
entity_type: entity_test
bundle: test_bundle_2
......
......@@ -150,7 +150,6 @@ public function testToArray() {
'uuid' => NULL,
'status' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_uuid' => NULL,
'field_name' => 'field_test',
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment