diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php index 434745e..d38b676 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php @@ -156,6 +156,15 @@ public function buildForm(array $form, array &$form_state) { '#rows' => 24, '#required' => TRUE, ); + $form['advanced'] = array( + '#type' => 'details', + '#title' => $this->t('Advanced'), + ); + $form['advanced']['custom_entity_id'] = array( + '#title' => $this->t('Custom Entity ID'), + '#type' => 'textfield', + '#description' => $this->t('Specify a custom entity ID. This will override the entity ID in the configuration above.'), + ); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', @@ -181,6 +190,13 @@ public function validateForm(array &$form, array &$form_state) { if ($form_state['values']['config_type'] !== 'system.simple') { $definition = $this->entityManager->getDefinition($form_state['values']['config_type']); $id_key = $definition->getKey('id'); + + // If a custom entity ID is specified, override the value in the + // configuration data being imported. + if (!empty($form_state['values']['custom_entity_id'])) { + $data[$id_key] = $form_state['values']['custom_entity_id']; + } + $entity_storage = $this->entityManager->getStorageController($form_state['values']['config_type']); // If an entity ID was not specified, set an error. if (!isset($data[$id_key])) { diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php index fbd7497..44521ad 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSingleImportExportTest.php @@ -73,6 +73,14 @@ public function testImport() { $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertText(t('An entity with this machine name already exists but the UUID does not match.')); + // Attempt an import with a mismatched UUID and a custom ID. + $edit['custom_entity_id'] = 'custom_id'; + $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); + $this->assertRaw(t('Are you sure you want to create new %name @type?', array('%name' => 'custom_id', '@type' => 'test configuration'))); + $this->drupalPostForm(NULL, array(), t('Confirm')); + $entity = $storage->load('custom_id'); + $this->assertRaw(t('The @entity_type %label was imported.', array('@entity_type' => 'config_test', '%label' => $entity->label()))); + // Perform an import with a unique ID and UUID. $import = <<