Commit d625f2c3 authored by alexpott's avatar alexpott

Issue #2030465 by swentel: Clean up entity form displays when deleting a bundle.

parent 91961228
......@@ -47,9 +47,8 @@ function entity_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
* Implements hook_entity_bundle_delete().
*/
function entity_entity_bundle_delete($entity_type, $bundle) {
$entity_info = entity_get_info('entity_display');
// Remove entity displays of the deleted bundle.
$entity_info = entity_get_info('entity_display');
$ids = config_get_storage_names_with_prefix('entity.display.' . $entity_type . '.' . $bundle);
foreach ($ids as &$id) {
$id = ConfigStorageController::getIDFromConfigName($id, $entity_info['config_prefix']);
......@@ -57,6 +56,7 @@ function entity_entity_bundle_delete($entity_type, $bundle) {
entity_delete_multiple('entity_display', $ids);
// Remove entity form displays of the deleted bundle.
$entity_info = entity_get_info('entity_form_display');
$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']);
......
......@@ -206,9 +206,10 @@ public function testRenameDeleteBundle() {
$this->installSchema('system', array('variable'));
$this->installSchema('node', array('node'));
// Create a node bundle and display object.
// Create a node bundle, display and form display object.
entity_create('node_type', array('type' => 'article'))->save();
entity_get_display('node', 'article', 'default')->save();
entity_get_form_display('node', 'article', 'default')->save();
// Rename the article bundle and assert the entity display is renamed.
$info = node_type_load('article');
......@@ -217,14 +218,21 @@ public function testRenameDeleteBundle() {
$info->save();
$old_display = entity_load('entity_display', 'node.article.default');
$this->assertFalse($old_display);
$old_form_display = entity_load('entity_form_display', 'node.article.default');
$this->assertFalse($old_form_display);
$new_display = entity_load('entity_display', 'node.article_rename.default');
$this->assertEqual('article_rename', $new_display->bundle);
$this->assertEqual('node.article_rename.default', $new_display->id);
$new_form_display = entity_load('entity_form_display', 'node.article_rename.default');
$this->assertEqual('article_rename', $new_form_display->bundle);
$this->assertEqual('node.article_rename.default', $new_form_display->id);
// Delete the bundle.
$info->delete();
$display = entity_load('entity_display', 'node.article_rename.default');
$this->assertFalse($display);
$form_display = entity_load('entity_form_display', 'node.article_rename.default');
$this->assertFalse($form_display);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment