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

8.0.x
Alex Pott 2014-07-03 12:26:19 +01:00
parent bd9eef3f3d
commit 18b755b237
7 changed files with 7 additions and 22 deletions

View File

@ -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'

View File

@ -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 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
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 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
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 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
if (!$instance->deleted) {
$config = $instance->toArray();
$config['deleted'] = TRUE;
$config['field_uuid'] = $instance->getFieldStorageDefinition()->uuid();
$deleted_instances[$instance->uuid()] = $config;
}
}
@ -440,7 +431,7 @@ class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfi
$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) {

View File

@ -143,7 +143,8 @@ class FieldInstanceConfigStorage extends ConfigEntityStorage {
break;
case 'field_id':
$checked_value = $instance->field_uuid;
case 'field_uuid':
$checked_value = $field->uuid();
break;
case 'uuid';

View File

@ -1,7 +1,6 @@
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

View File

@ -1,7 +1,6 @@
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

View File

@ -1,7 +1,6 @@
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

View File

@ -150,7 +150,6 @@ class FieldInstanceConfigEntityUnitTest extends UnitTestCase {
'uuid' => NULL,
'status' => TRUE,
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'field_uuid' => NULL,
'field_name' => 'field_test',
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle',