Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
224
Merge Requests
224
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
d625f2c3
Commit
d625f2c3
authored
Jun 30, 2013
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2030465
by swentel: Clean up entity form displays when deleting a bundle.
parent
91961228
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
core/modules/entity/entity.module
core/modules/entity/entity.module
+2
-2
core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
...ules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
+9
-1
No files found.
core/modules/entity/entity.module
View file @
d625f2c3
...
@@ -47,9 +47,8 @@ function entity_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
...
@@ -47,9 +47,8 @@ function entity_entity_bundle_rename($entity_type, $bundle_old, $bundle_new) {
* Implements hook_entity_bundle_delete().
* Implements hook_entity_bundle_delete().
*/
*/
function
entity_entity_bundle_delete
(
$entity_type
,
$bundle
)
{
function
entity_entity_bundle_delete
(
$entity_type
,
$bundle
)
{
$entity_info
=
entity_get_info
(
'entity_display'
);
// Remove entity displays of the deleted bundle.
// 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
);
$ids
=
config_get_storage_names_with_prefix
(
'entity.display.'
.
$entity_type
.
'.'
.
$bundle
);
foreach
(
$ids
as
&
$id
)
{
foreach
(
$ids
as
&
$id
)
{
$id
=
ConfigStorageController
::
getIDFromConfigName
(
$id
,
$entity_info
[
'config_prefix'
]);
$id
=
ConfigStorageController
::
getIDFromConfigName
(
$id
,
$entity_info
[
'config_prefix'
]);
...
@@ -57,6 +56,7 @@ function entity_entity_bundle_delete($entity_type, $bundle) {
...
@@ -57,6 +56,7 @@ function entity_entity_bundle_delete($entity_type, $bundle) {
entity_delete_multiple
(
'entity_display'
,
$ids
);
entity_delete_multiple
(
'entity_display'
,
$ids
);
// Remove entity form displays of the deleted bundle.
// 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
);
$ids
=
config_get_storage_names_with_prefix
(
'entity.form_display.'
.
$entity_type
.
'.'
.
$bundle
);
foreach
(
$ids
as
&
$id
)
{
foreach
(
$ids
as
&
$id
)
{
$id
=
ConfigStorageController
::
getIDFromConfigName
(
$id
,
$entity_info
[
'config_prefix'
]);
$id
=
ConfigStorageController
::
getIDFromConfigName
(
$id
,
$entity_info
[
'config_prefix'
]);
...
...
core/modules/entity/lib/Drupal/entity/Tests/EntityDisplayTest.php
View file @
d625f2c3
...
@@ -206,9 +206,10 @@ public function testRenameDeleteBundle() {
...
@@ -206,9 +206,10 @@ public function testRenameDeleteBundle() {
$this
->
installSchema
(
'system'
,
array
(
'variable'
));
$this
->
installSchema
(
'system'
,
array
(
'variable'
));
$this
->
installSchema
(
'node'
,
array
(
'node'
));
$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_create
(
'node_type'
,
array
(
'type'
=>
'article'
))
->
save
();
entity_get_display
(
'node'
,
'article'
,
'default'
)
->
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.
// Rename the article bundle and assert the entity display is renamed.
$info
=
node_type_load
(
'article'
);
$info
=
node_type_load
(
'article'
);
...
@@ -217,14 +218,21 @@ public function testRenameDeleteBundle() {
...
@@ -217,14 +218,21 @@ public function testRenameDeleteBundle() {
$info
->
save
();
$info
->
save
();
$old_display
=
entity_load
(
'entity_display'
,
'node.article.default'
);
$old_display
=
entity_load
(
'entity_display'
,
'node.article.default'
);
$this
->
assertFalse
(
$old_display
);
$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'
);
$new_display
=
entity_load
(
'entity_display'
,
'node.article_rename.default'
);
$this
->
assertEqual
(
'article_rename'
,
$new_display
->
bundle
);
$this
->
assertEqual
(
'article_rename'
,
$new_display
->
bundle
);
$this
->
assertEqual
(
'node.article_rename.default'
,
$new_display
->
id
);
$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.
// Delete the bundle.
$info
->
delete
();
$info
->
delete
();
$display
=
entity_load
(
'entity_display'
,
'node.article_rename.default'
);
$display
=
entity_load
(
'entity_display'
,
'node.article_rename.default'
);
$this
->
assertFalse
(
$display
);
$this
->
assertFalse
(
$display
);
$form_display
=
entity_load
(
'entity_form_display'
,
'node.article_rename.default'
);
$this
->
assertFalse
(
$form_display
);
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment