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 |
---|---|---|---|
#29 | editor-2030605-29.patch | 46.04 KB | tim.plunkett |
Comments
Comment #1
Wim LeersI tried to do this, but failed, because it's not at all clear what needs to happen. Postponed on feedback at #2016679-13: Expand Entity Type interfaces to provide methods, protect the properties.
Comment #2
Wim LeersI did this because of #2016679-14: Expand Entity Type interfaces to provide methods, protect the properties and #15. But I still don't get *why*. See #16 there.
Comment #3
Wim LeersAfter a brief chat with Berdir, it is clear that I missed the key point in the #2 patch. Fixing that.
Comment #4
Wim LeersEditor->editor
andEditor->settings
should be protected.Editor->format
can't be protected yet because it's an entity key.Comment #5
Wim Leers.
Comment #6
Wim LeersSince #2016679-29: Expand Entity Type interfaces to provide methods, protect the properties, I finally fully grok the what and why. I'll make this happen.
Comment #7
daffie CreditAttribution: daffie commented3: expand_editor_methods-2030605-3.patch queued for re-testing.
Comment #9
daffie CreditAttribution: daffie commentedI have tried to do a review. But the patch failed me.
There are a lot of changes to this module since jan 9th.
For instance in the file CKEditorPluginManager.php there is a change made to the function getEnabledPlugins, only that function no longer exists.
Comment #10
Wim LeersNo need to post the entire list of failures. Just saying "the patch doesn't apply anymore" is enough :) ;)
If you want to work on this, I'll review your patches!
Comment #11
daffie CreditAttribution: daffie commentedComment #12
Wim LeersHurray — thanks, daffie! :)
Comment #13
webwarrior CreditAttribution: webwarrior commentedWorking on it as part of core mentoring hours
Comment #14
Wim LeersYay :) I'll provide reviews!
Comment #15
webwarrior CreditAttribution: webwarrior commentedComment #17
webwarrior CreditAttribution: webwarrior commentedOk sorry, misunderstood that one, let's try again.
Comment #18
mr.baileysAssigning to me for review (DDD Szeged sprint).
Comment #19
mr.baileys$format
property, for which no getter/setter is added in this patch. I wanted to convert it to a protected property, but this causes the ConfigStorageController to fail. Ok to leave public without adding a getter (since I assume getFilterFormat() should be used)? I did add a @see directive pointing to getFilterFormat().editor_form_filter_admin_format_submit()
still uses the$settings
-property directly instead of using the &getSettings() getter. Is that acceptable, or should all uses of the property be replaced?Wim Leers & I looked into 2 exceptions that occur during Editor Admin Testing. However, both exceptions also occur on a clean 8.x HEAD (confirmed on two separate environments). Setting to needs review to see how the testbot reacts.
Comment #20
Wim LeersI hadn't actually seen the patch mr.baileys worked on, we just discussed a few things (as he mentioned). Patch looks good to me. The second bullet in #19 needs feedback from e.g. Tim Plunkett, whom I just pinged.
Thanks! :)
Comment #21
tim.plunkett#19.2 is a good question, and one that had me confused at first.
Because it's declared as the ID key, $editor->format is the same as $editor->id(). I need to file an issue about ConfigStorageController assuming that's public, but for now you should leave it public. One other thing to consider (so that everyone stops having the same confusion) is to rename $editor->format to $editor->id, like 90% of the other entity types.
I didn't review the patch yet, but just use ->id() where appropriate, and I'll crosslink the ConfigStorageController issue when I create it.
Comment #22
tim.plunkettThis makes me wonder if a
function getSetting($key)
method would be a nice addition.I think these are redundant
These should repeat the variable name
Generally we make our setters fluent, meaning they should return $this so they can be chained. The docblock should say
@return $this
, no description needed on the next line.I think this (and the setter) should be getImageUploadSettings(). I would expect a method called getImageUpload to return a file or something
Out-of-scope follow-up: It'd be nice to have a helper method for this
Comment #23
mr.baileysThanks for the review!
1. This function returns a nested array, wouldn't adding a getSetting($key) lead to awkward invocations like
$this->getSettings('toolbar')['rows']
?2-5. Fixed
6. leaving for a follow-up.
Comment #24
tim.plunkett#2224833: Remove redundant ID manipulation in ConfigEntityStorage::save() removed the need for a public ID property
Comment #25
Wim LeersEntityInterface::toArray()
then. Left a comment at #2016679-54: Expand Entity Type interfaces to provide methods, protect the properties regarding that.IMO this is now good to go.
Comment #26
Wim LeersComment #27
tim.plunkettLooks great, thanks Wim!
Comment #29
tim.plunkettQuick reroll, minor conflict with #2225955: Improve the DX of writing entity storage classes.
Comment #30
Wim Leers#29: thanks for the reroll! :)
Comment #32
mr.baileysHrm. Not sure why the patch was marked as failed testing, since it is showing up green and there are no failures or exceptions in the test log, so back to RTBC.
Comment #33
mr.baileys29: editor-2030605-29.patch queued for re-testing.
Comment #34
webchickLooks consistent with other patches doing a similar thing.
Committed and pushed to 8.x. Thanks!
Comment #36
Wim Leers