Follow up for #1871772-108: Convert custom blocks to content entities
Problem/Motivation
+++ b/core/modules/block/custom_block/custom_block.module
@@ -53,3 +157,161 @@ function theme_custom_block_block($variables) {
+function custom_block_add_body_field($block_type_id, $label = 'Block body') {
Minor: Should default to just "Body", I think.
+++ b/core/modules/block/custom_block/custom_block.module
@@ -53,3 +157,161 @@ function theme_custom_block_block($variables) {
+ $field = field_info_field('block_body');
+ $instance = field_info_instance('custom_block', 'block_body', $block_type_id);
...
+ 'field_name' => 'block_body',
I'm concerned about module namespace issues here; technically, this module-specific field should at least start with "custom_block_" as it is owned by custom_block.module.
Proposed resolution
Rename the field and the default title, refactor upgrade path
Remaining tasks
Rename the field and the default title, refactor upgrade path
Comment | File | Size | Author |
---|---|---|---|
#14 | custom-block-field-rename-1919916-14.patch | 2.4 KB | oadaeh |
#11 | custom-block-field-name.11.patch | 9.31 KB | oadaeh |
#10 | custom-block-field-name.10.patch | 11.66 KB | larowlan |
#6 | change-block-body-1919916-6.patch | 2.51 KB | jessehs |
#4 | 1919916-Refactored-label-of-custom-block-body-4.patch | 1.28 KB | babruix |
Comments
Comment #1
larowlanchanging tags
Comment #2
sunComment #3
babruix CreditAttribution: babruix commentedComment #4
babruix CreditAttribution: babruix commentedChanged 'Block body' to just 'Body'.
About fixing title we need more clarification.
Also I`m concerned about this code:
Why we need $field variable is it never used after?
Comment #6
jessehsRe-roll of #4, but now also changing tests to look for the updated label.
Comment #7
jessehsComment #9
larowlanThis should be postponed until #1920862: Rename custom_block.module to block_content.module goes in, as the machine name of the module will be changed
Comment #10
larowlanActually, not really - because the script used to do the rename in #1920862: Rename custom_block.module to block_content.module will catch the custom_block reference in the field machine name and rename that too.
This should fix the tests and update the machine name too.
Comment #11
oadaeh CreditAttribution: oadaeh commentedThe patch in #10 no longer applies.
I've manually recreated it.
It seems that testCustomBlock() no loner exists in core/modules/block/lib/Drupal/block/Tests/BlockTest.php, or in fact, anywhere.
Comment #13
andypostI see no reason to make name prefixed with "custom_block_" please make it inline with node module - just name it "block", in d8 different entity types could have same-named fields
Comment #14
oadaeh CreditAttribution: oadaeh commentedBased on @andypost's comment and the fact that much of what the original patch modified is no longer available or already changed differently, I've attached a patch that basically does nothing more than change the default text from "Block body" to "Body".
Comment #15
sunI agree with the scope change. The machine name issue should have been a separate issue right from the start. :-)
RTBC, unless testbot disagrees ;)
Comment #16
alexpottCommitted 9d8aa13 and pushed to 8.x. Thanks!
Comment #18
Wim LeersYay! At last! :)