diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php index 61627b8..6e75e6e 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBundleBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Config\Entity; use Drupal\Core\Config\ConfigNameException; -use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface; /** @@ -90,9 +89,7 @@ public function preSave(EntityStorageInterface $storage) { $bundle_type = $this->getEntityType(); $bundle_of = $bundle_type->getBundleOf(); if (!empty($bundle_of)) { - throw new ConfigNameException(t("The machine name of this @bundle cannot be changed.", [ - '@bundle' => $bundle_type->getLabel(), - ])); + throw new ConfigNameException("The machine name of the '{$bundle_type->getLabel()}' bundle cannot be changed."); } } diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index 31a25a1..f6ac384 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -350,6 +350,7 @@ * 'bundle_entity_type' on the \Drupal\node\Entity\Node class. Also, the * bundle config entity type annotation must have a 'bundle_of' entry, * giving the machine name of the entity type it is acting as a bundle for. + * These machine names are considered permanent, they may not be renamed. * - Additional annotations can be seen on entity class examples such as * \Drupal\node\Entity\Node (content) and \Drupal\user\Entity\Role * (configuration). These annotations are documented on diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index a4059d2..abb16eb 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -312,9 +312,9 @@ public function testDeleteBundle() { // Delete the bundle. $type->delete(); - $display = entity_load('entity_view_display', 'node.article_rename.default'); + $display = entity_load('entity_view_display', 'node.article.default'); $this->assertFalse((bool) $display); - $form_display = entity_load('entity_form_display', 'node.article_rename.default'); + $form_display = entity_load('entity_form_display', 'node.article.default'); $this->assertFalse((bool) $form_display); } diff --git a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php index 349c8ee..9591618 100644 --- a/core/modules/language/src/Tests/LanguageConfigurationElementTest.php +++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php @@ -152,6 +152,39 @@ public function testDefaultLangcode() { } /** + * Tests that the configuration is retained when the node type is updated. + */ + public function testNodeTypeUpdate() { + // Create the article content type first if the profile used is not the + // standard one. + if ($this->profile != 'standard') { + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); + } + $admin_user = $this->drupalCreateUser(array('administer content types')); + $this->drupalLogin($admin_user); + $edit = array( + 'language_configuration[langcode]' => 'current_interface', + 'language_configuration[language_alterable]' => TRUE, + ); + $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); + // Check the language default configuration for the articles. + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article'); + $uuid = $configuration->uuid(); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Article content type.'); + $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Article content type.'); + // Update the article content type by changing the title label. + $edit = array( + 'title_label' => 'Name' + ); + $this->drupalPostForm('admin/structure/types/manage/article', $edit, t('Save content type')); + // Check that we still have the settings for the updated node type. + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('node', 'article'); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been kept on the updated Article content type.'); + $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been kept on the updated Article content type.'); + $this->assertEqual($configuration->uuid(), $uuid, 'The language configuration uuid has been kept on the updated Article content type.'); + } + + /** * Tests the language settings are deleted on bundle delete. */ public function testNodeTypeDelete() { @@ -186,4 +219,39 @@ public function testNodeTypeDelete() { $this->assertFalse($configuration, 'The language configuration was deleted after bundle was deleted.'); } + /** + * Tests that the configuration is retained when a vocabulary is updated. + */ + public function testTaxonomyVocabularyUpdate() { + $vocabulary = entity_create('taxonomy_vocabulary', array( + 'name' => 'Country', + 'vid' => 'country', + )); + $vocabulary->save(); + + $admin_user = $this->drupalCreateUser(array('administer taxonomy')); + $this->drupalLogin($admin_user); + $edit = array( + 'default_language[langcode]' => 'current_interface', + 'default_language[language_alterable]' => TRUE, + ); + $this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save')); + + // Check the language default configuration. + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country'); + $uuid = $configuration->uuid(); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been saved on the Country vocabulary.'); + $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been saved on the Country vocabulary.'); + // Update the vocabulary. + $edit = array( + 'name' => 'Nation' + ); + $this->drupalPostForm('admin/structure/taxonomy/manage/country', $edit, t('Save')); + // Check that we still have the settings for the updated vocabulary. + $configuration = ContentLanguageSettings::loadByEntityTypeBundle('taxonomy_term', 'country'); + $this->assertEqual($configuration->getDefaultLangcode(), 'current_interface', 'The default language configuration has been kept on the updated Country vocabulary.'); + $this->assertTrue($configuration->isLanguageAlterable(), 'The alterable language configuration has been kept on the updated Country vocabulary.'); + $this->assertEqual($configuration->uuid(), $uuid, 'The language configuration uuid has been kept on the updated Country vocabulary.'); + } + }