diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index fa603d2..b896b7d 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -168,7 +168,7 @@ public function getMachineNameSuggestion() { $transliteration_service = \Drupal::transliteration(); $transliterated = $transliteration_service->transliterate($admin_label, Language::LANGCODE_DEFAULT, '_'); - $replace_pattern = '[^a-z0-9_.]+'; + $replace_pattern = '[^a-z0-9_]+'; $transliterated = Unicode::strtolower($transliterated); diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 92d3696..969d807 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -103,7 +103,6 @@ public function form(array $form, array &$form_state) { '#default_value' => !$entity->isNew() ? $entity->id() : $this->getUniqueMachineName($entity), '#machine_name' => array( 'exists' => 'block_load', - 'replace_pattern' => '[^a-z0-9_.]+', 'source' => array('settings', 'label'), ), '#required' => TRUE, diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php index 58fc2d5..e7d0b42 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImportUITest.php @@ -37,7 +37,7 @@ function setUp() { */ function testImport() { $name = 'system.site'; - $dynamic_name = 'config_test.dynamic.new'; + $dynamic_name = 'config_test.dynamic.new.test'; $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); @@ -52,7 +52,7 @@ function testImport() { // Create new config entity. $original_dynamic_data = array( - 'id' => 'new', + 'id' => 'new.test', 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'weight' => 0, diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php index cb4aeaa..772c230 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigImporterTest.php @@ -135,7 +135,7 @@ function testDeleted() { * Tests creation of configuration during import. */ function testNew() { - $dynamic_name = 'config_test.dynamic.new'; + $dynamic_name = 'config_test.dynamic.new.test'; $storage = $this->container->get('config.storage'); $staging = $this->container->get('config.storage.staging'); @@ -144,7 +144,7 @@ function testNew() { // Create new config entity. $original_dynamic_data = array( - 'id' => 'new', + 'id' => 'new.test', 'uuid' => '30df59bd-7b03-4cf7-bb35-d42fc49f0651', 'label' => 'New', 'weight' => 0, diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php index 3bb7839..f8f21a1 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigInstallWebTest.php @@ -34,7 +34,7 @@ function setUp() { */ function testIntegrationModuleReinstallation() { $default_config = 'config_integration_test.settings'; - $default_configuration_entity = 'config_test.dynamic.config_integration_test'; + $default_configuration_entity = 'config_test.dynamic.config_integration.test'; // Install the config_test module we're integrating with. \Drupal::moduleHandler()->install(array('config_test')); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigOtherModuleTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigOtherModuleTest.php index 90915fc..bfb6569 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigOtherModuleTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigOtherModuleTest.php @@ -44,24 +44,24 @@ public function testInstallOtherModuleFirst() { // Check that the config entity doesn't exist before the config_test module // is enabled. We cannot use the entity system because the config_test // entity type does not exist. - $config = $this->container->get('config.factory')->get('config_test.dynamic.other_module'); + $config = $this->container->get('config.factory')->get('config_test.dynamic.other.module'); $this->assertTrue($config->isNew(), 'Default configuration for other modules is not installed if that module is not enabled.'); // Install the module that provides the entity type. This installs the // default configuration. $this->moduleHandler->install(array('config_test')); - $this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration has been installed.'); + $this->assertTrue(entity_load('config_test', 'other.module', TRUE), 'Default configuration has been installed.'); // Uninstall the module that provides the entity type. This will remove the // default configuration. $this->moduleHandler->uninstall(array('config_test')); - $config = $this->container->get('config.factory')->get('config_test.dynamic.other_module'); + $config = $this->container->get('config.factory')->get('config_test.dynamic.other.module'); $this->assertTrue($config->isNew(), 'Default configuration for other modules is removed when the config entity provider is disabled.'); // Install the module that provides the entity type again. This installs the // default configuration. $this->moduleHandler->install(array('config_test')); - $other_module_config_entity = entity_load('config_test', 'other_module', TRUE); + $other_module_config_entity = entity_load('config_test', 'other.module', TRUE); $this->assertTrue($other_module_config_entity, "Default configuration has been recreated."); // Update the default configuration to test that the changes are preserved @@ -71,14 +71,14 @@ public function testInstallOtherModuleFirst() { // Uninstall the module that provides the default configuration. $this->moduleHandler->uninstall(array('config_other_module_config')); - $this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration for other modules is not removed when the module that provides it is uninstalled.'); + $this->assertTrue(entity_load('config_test', 'other.module', TRUE), 'Default configuration for other modules is not removed when the module that provides it is uninstalled.'); // Default configuration provided by config_test should still exist. $this->assertTrue(entity_load('config_test', 'dotted.default', TRUE), 'The configuration is not deleted.'); // Re-enable module to test that default config is unchanged. $this->moduleHandler->install(array('config_other_module_config')); - $config_entity = entity_load('config_test', 'other_module', TRUE); + $config_entity = entity_load('config_test', 'other.module', TRUE); $this->assertEqual($config_entity->get('style'), "The piano ain't got no wrong notes.", 'Re-enabling the module does not install default config over the existing config entity.'); } @@ -87,10 +87,10 @@ public function testInstallOtherModuleFirst() { */ public function testInstallConfigEnityModuleFirst() { $this->moduleHandler->install(array('config_test')); - $this->assertFalse(entity_load('config_test', 'other_module', TRUE), 'Default configuration provided by config_other_module_config does not exist.'); + $this->assertFalse(entity_load('config_test', 'other.module', TRUE), 'Default configuration provided by config_other_module_config does not exist.'); $this->moduleHandler->install(array('config_other_module_config')); - $this->assertTrue(entity_load('config_test', 'other_module', TRUE), 'Default configuration provided by config_other_module_config has been installed.'); + $this->assertTrue(entity_load('config_test', 'other.module', TRUE), 'Default configuration provided by config_other_module_config has been installed.'); } } diff --git a/core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration_test.yml b/core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration.test.yml similarity index 60% rename from core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration_test.yml rename to core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration.test.yml index f87b942..7e9215d 100644 --- a/core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration_test.yml +++ b/core/modules/config/tests/config_integration_test/config/config_test.dynamic.config_integration.test.yml @@ -1,2 +1,2 @@ -id: config_integration_test +id: config_integration.test label: 'Default integration config label' diff --git a/core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other_module.yml b/core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other.module.yml similarity index 89% rename from core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other_module.yml rename to core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other.module.yml index b144af6..8fdb1e9 100644 --- a/core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other_module.yml +++ b/core/modules/config/tests/config_other_module_config/config/config_test.dynamic.other.module.yml @@ -1,4 +1,4 @@ -id: other_module +id: other.module uuid: 486f9f5c-82ed-4add-a700-b0ee3af4d17d label: 'Other module' weight: '0' diff --git a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml index 04329ab..9f02156 100644 --- a/core/modules/config/tests/config_test/config/schema/config_test.schema.yml +++ b/core/modules/config/tests/config_test/config/schema/config_test.schema.yml @@ -72,7 +72,7 @@ config_test.someschema.somemodule.*.*: type: text label: 'Description' -config_test.dynamic.*: +config_test.dynamic.*.*: type: mapping label: 'Config test entity' mapping: diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php index 6eb2d2f..3d6c5f7 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php @@ -30,15 +30,6 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL) /** * {@inheritdoc} */ - public function validate(array $form, array &$form_state) { - parent::validate($form, $form_state); - - form_set_value($form['id'], $this->entityType . '.' . $form_state['values']['id'], $form_state); - } - - /** - * {@inheritdoc} - */ protected function prepareEntity() { $definition = $this->entityManager->getDefinition($this->entityType); if (!$definition['fieldable'] || !isset($definition['controllers']['render'])) { diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 93f595c..05254c6 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -80,15 +80,22 @@ public function form(array $form, array &$form_state) { '#default_value' => $this->entity->label(), ); + if ($this->entity->isNew()) { + $machine_name = ''; + } + else { + // The ID will be in the form "entity_type.user_configured_name". The + // entity type is prefixed during saving. + // @see \Drupal\entity\Form\EntityDisplayModeFormBase::save() + list(, $machine_name) = explode('.', $this->entity->id()); + } $form['id'] = array( '#type' => 'machine_name', '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#disabled' => !$this->entity->isNew(), - '#default_value' => $this->entity->id(), - '#field_prefix' => $this->entity->isNew() ? $this->entity->getTargetType() . '.' : '', + '#default_value' => $machine_name, '#machine_name' => array( 'exists' => array($this, 'exists'), - 'replace_pattern' => '[^a-z0-9_.]+', ), ); @@ -111,7 +118,7 @@ public function form(array $form, array &$form_state) { public function exists($entity_id, array $element, array $form_state) { return (bool) $this->queryFactory ->get($this->entity->entityType()) - ->condition('id', $element['#field_prefix'] . $entity_id) + ->condition('id', $this->entity->getTargetType() . '.' . $entity_id) ->execute(); } @@ -119,6 +126,7 @@ public function exists($entity_id, array $element, array $form_state) { * {@inheritdoc} */ public function save(array $form, array &$form_state) { + $this->entity->id = $this->entity->getTargetType() . '.' . $this->entity->id(); drupal_set_message(t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => strtolower($this->entityInfo['label'])))); $this->entity->save(); entity_info_cache_clear();