diff --git a/core/modules/entity/entity.module b/core/modules/entity/entity.module index efb7e44..09776fa 100644 --- a/core/modules/entity/entity.module +++ b/core/modules/entity/entity.module @@ -7,3 +7,39 @@ * The module is mostly an anchor point for configuration items owned by the * entity system. */ + +use Drupal\Core\Config\Entity\ConfigStorageController; + +/** + * Implements hook_field_attach_rename_bundle(). + */ +function entity_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_new) { + $entity_info = entity_get_info('entity_form_display'); + + // Rename entity displays. + if ($bundle_old !== $bundle_new) { + $ids = config_get_storage_names_with_prefix('entity.form_display.' . $entity_type . '.' . $bundle_old); + foreach ($ids as $id) { + $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']); + $form_display = entity_load('entity_form_display', $id); + $new_id = $entity_type . '.' . $bundle_new . '.' . $form_display->formMode; + $form_display->id = $new_id; + $form_display->bundle = $bundle_new; + $form_display->save(); + } + } +} + +/** + * Implements hook_field_attach_delete_bundle(). + */ +function entity_field_attach_delete_bundle($entity_type, $bundle, $instances) { + $entity_info = entity_get_info('entity_form_display'); + + // Remove entity displays of the deleted bundle. + $ids = config_get_storage_names_with_prefix('entity.form_display.' . $entity_type . '.' . $bundle); + foreach ($ids as &$id) { + $id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']); + } + entity_delete_multiple('entity_form_display', $ids); +} diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php index 229e546..f2855c7 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Tests/ManageFieldsTest.php @@ -394,10 +394,8 @@ function testHiddenFields() { /** * Tests renaming a bundle. - * - * @todo Bring back this test when http://drupal.org/node/1950326 is fixed. */ - function XtestRenameBundle() { + function testRenameBundle() { $type2 = strtolower($this->randomName(8)) . '_test'; $options = array( diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php index 6f99dae..5d917a4 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/RdfaMarkupTest.php @@ -117,6 +117,12 @@ function testAttributesInMarkupFile() { 'bundle' => $bundle_name, ); field_create_instance($instance); + + entity_get_form_display('node', $bundle_name, 'default') + ->setComponent($field_name, array( + 'type' => 'file_generic', + )) + ->save(); entity_get_display('node', $bundle_name, 'teaser') ->setComponent($field_name, array( 'type' => 'file_default',