Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Part of meta-issue #2016679: Expand Entity Type interfaces to provide methods, protect the properties.
See the detailed explanations there and look at the issues that already have patches or were commited.
Add get*, set* and additional methods as it makes sense to replace the public properties (e.g. isSomething() and something())
Comment | File | Size | Author |
---|---|---|---|
#35 | block-interface-2028035.34.patch | 23.84 KB | larowlan |
#24 | drupal8.custom-block.module.2028035-24.patch | 25.06 KB | johnennew |
#18 | customblockinterface-with-methods-2028035-17.patch | 25.37 KB | johnennew |
#18 | interdiff-2028035-14-17.txt | 2.59 KB | johnennew |
#14 | customblockinterface-with-methods-2028035-14.patch | 24.24 KB | Berdir |
Comments
Comment #1
David Hernández CreditAttribution: David Hernández commentedWorking on this.
Comment #2
David Hernández CreditAttribution: David Hernández commentedI'm unassigning this issue from me as I will be helping somewhere else. Maybe I will be back to this later, but as I'm not sure, I prefer to leave it unassigned, just in case anyone wants to continue with it.
Anyways, I'm adding a initial patch with part of the changes (most of the getters). Is still necessary to create the required setters and update the code of the CustomBlock class.
Comment #3
YesCT CreditAttribution: YesCT commentedComment #5
David Hernández CreditAttribution: David Hernández commentedReassigning this back to me.
Comment #6
David Hernández CreditAttribution: David Hernández commentedAttaching an almost-green patch. Still working on it.
Comment #7
David Hernández CreditAttribution: David Hernández commentedChanging status
Comment #9
David Hernández CreditAttribution: David Hernández commentedUnassigned
Comment #10
tim.plunkettComment #11
BerdirRemoved unnecessary methods and converted a lot of code to method calls and related cleanup.
Comment #13
larowlanTagging
Comment #14
BerdirFixed the revision id test, I have no idea how that is passing right now, it is wrong.
isDefaultRevision is a protected property that goes through __set() which adds it to $this->values. Not what you want...
Removed getInfo() in favor of label().
Comment #15
BerdirUps.
Comment #17
DizzyC CreditAttribution: DizzyC commentedComment #18
johnennew CreditAttribution: johnennew commentedTests are failing correctly as last patch breaks the ability to translate a block using the content_translate module.
Attached is a patch which should pass the tests (they do locally). Why this small change makes a difference I do not know and makes no sense to me!
Fragment which caused the tests to pass and fixes the functionality with content translation from the patch in #14. In core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php
I assume we do not want to store the langcode on the block class. The original patch in #14 seems to be the right way to set the langcode on a new block which is a translation of another but doing this breaks the association between the newly translated block and the original block. It appears like the langcode form field is doing different things in different situations which makes is difficult to diagnose.
Comment #19
BerdirUh, oh, thanks for tracking that down!
Seems like a case for @plach to look into.
Comment #20
plachNo time to look into this right now, but the change does not look good to me at first sight, although it fixes tests. We want to encourage people to always use the
langcode()
method otherwise translations would stop working. Did you try$block->getUntranslated()->language()->id
?Comment #21
BerdirAh, right. ->langcode is not translatable, so $entity->getTranslation('de')->langcode->value is still the old langcode.
I remember that we had to do this as well for the config/content entity issue.
That's... confusing. Can we do something about it?
Comment #22
BerdirSomeone up for a quick re-roll and try the approach suggested in #20?
Comment #23
johnennew CreditAttribution: johnennew commentedLooks like this is needs a re-roll as well. I'll give it a go now
Comment #24
johnennew CreditAttribution: johnennew commented@plach's suggestion in #20 appears to work, rerolled patch attached. Interdiff isn't working.
Comment #25
Berdir#24: drupal8.custom-block.module.2028035-24.patch queued for re-testing.
Comment #27
vladan.me CreditAttribution: vladan.me commentedTrying to reroll #24
Comment #28
BerdirLooks like the $block_type assignment moved below the other change, making the diff bigger than it has to by. Try to move it back into the original order to keep the necessary changes as small as possible.
Now that I look at this again, why do we even need this stuff? Shouldn't be here IMHO.
Try to remove those two form definitions and see what happens.
It seems this is just moved to a different location. Just like the first example, try to move it to the original location to keep the patch size down and make it easier to review.
Comment #29
vladan.me CreditAttribution: vladan.me commentedUploading patch according to #28
Comment #30
vladan.me CreditAttribution: vladan.me commentedComment #31
Berdirinfo needs to be $info, didn't notice that before.
Should be CustomBlock*Interface*.
Comment #32
vladan.me CreditAttribution: vladan.me commentedLooking good now?
Comment #33
larowlan32: drupal8_custom-block-module-1.patch queued for re-testing.
Comment #35
larowlanno longer applies, re-roll
Comment #36
larowlanThis is ready, I only rerolled so reckon I'm clear to Rtbc
Comment #37
catchCommitted/pushed to 8.x, thanks!
Comment #38
catchCommitted/pushed to 8.x, thanks!