Problem/Motivation
The concept of PluginBags was introduced by views and then expanded to a half dozen other entity types.
They provide a way to lazily instantiate a set of plugin instances.
The suffix Bag was chosen due to its assumed similarity to ParameterBag, FlashBag, etc.
However, it is supposed to mean that the object contains a set of variables or parameters (values).
A Collection is an ordered map of values or other objects.
Additionally, PluginBag (or PluginCollection) doesn't explain its true feature, the laziness.
Proposed resolution
- Rename PluginBag to LazyPluginCollection
- Rename classes that extend LazyPluginCollection accordingly. See #28.
Remaining tasks
get feedback on release management (can it go in during this phase of the beta?)- Finish items found in review.
before
PluginBag
-- DefaultPluginBag
---- ConditionPluginBag
---- FilterBag
---- ImageEffectBag
---- TipsBag
---- DisplayBag
-- DefaultSinglePluginBag
---- ActionBag
---- BlockPluginBag
---- SearchPluginBag
-- TestPluginBag
PluginBagTestBase
-- ConfigurablePluginBagTest
-- DefaultPluginBagTest
-- DefaultSinglePluginBagTest
EntityWithPluginBagsInterface
ConfigEntityBaseWithPluginBags
SearchPluginBagTest
after
LazyPluginCollection
-- DefaultLazyPluginCollection
---- ConditionPluginCollection
---- FilterPluginCollection
---- ImageEffectPluginCollection
---- TipsPluginCollection
---- DisplayPluginCollection
-- DefaultSingleLazyPluginCollection
---- ActionPluginCollection
---- BlockPluginCollection
---- SearchPluginCollection
-- TestLazyPluginCollection
LazyPluginCollectionTestBase
-- ConfigurablePluginCollectionTest
-- DefaultLazyPluginCollectionTest
-- DefaultSingleLazyPluginCollectionTest
EntityWithPluginCollectionInterface
ConfigEntityBaseWithPluginCollections
SearchPluginCollectionTest
User interface changes
N/A
API changes
Yes, all existing base classes and interfaces will change. See the change record.
| Comment | File | Size | Author |
|---|---|---|---|
| #41 | rename_pluginbag_to-2246647-41.patch | 88.94 KB | mpdonadio |
| #41 | interdiff-32-41.txt | 20.32 KB | mpdonadio |
| #32 | rename_pluginbag_to-2246647-32.patch | 88.67 KB | cilefen |
Comments
Comment #1
tim.plunkettPerformed renames with phpstorm. Also found some vestigial code.
Comment #2
xjmFor what it's worth,
PluginBagalways terrified me, because suddenly I thought there was some deep Symfony concept I was missing to know how Views plugins worked.LazyPluginCollectionis a much more self-explanatory name. :) So +1 for the rename, even though it's kinda a disruptive patch.There's a few change records that would need updates:
https://drupal.org/list-changes/published/drupal?keywords_description=ba...
And plus we'd want one for this issue itself.
Comment #3
xjmComment #4
yesct commentedI read the whole patch.
Places that are not simple renames look totally fine. So (for what it is worth) all these changes are good to me.
other comment blocks are re-wrapped, so wrapping this one also.
and in 2 other places. see interdiff.
new test? or a rename that didn't match enough?
ah, I see, a move. ok.
core/modules/image/lib/Drupal/image/Entity/ImageStyle.php
84: protected $effectsBag;
350: if (!$this->effectsBag) {
351: $this->effectsBag = new ImageEffectCollection(\Drupal::service('plugin.manager.image.effect'), $this->effects);
352: $this->effectsBag->sort();
354: return $this->effectsBag;
These should have been renamed also?
Comment #5
dawehnerIs this still on the table? We use Bag and Collection in various places, but I really like the "Lazy"-ness here, as it tells you more what this is actually about.
Comment #6
mfernea commentedI'll try to do the reroll.
Comment #7
mfernea commentedIt's a "little bit" too much for me. :)
Comment #8
cilefen commentedRerolled by hand because so much has changed.
Comment #9
yesct commentedComment #10
yesct commentedreviewing this.
Comment #11
fabianx commentedRTBC from my POV, but this is a BC break, so justifying that:
- PluginBag is not only a strange name, but this is _not_ a bag, but a collection, such it is a violation of Symfony standards, which we try to apply to and can be very misleading if people try to use it as a bag.
Therefore the rename is well worth it. It is also easy to do the same in contrib/ modules that might be broken by that change as it is mainly a simple string / replace.
So while the rename is very broad, it is simple to port as the overall API remains the same.
Comment #12
yesct commentedStarted looking at this. As I got more and more into it, I wondered if 'beta target' was accurate. This seems like it might not be allowed in at this point.
discussed with xjm. based on where we are in the beta, the benefit here may not outweigh the disruption, and we need some maintainer feedback to clarify that. let's wait for input here, and also maybe a post about beta changes criteria generally.
But did finish looking through it... posting the nits (I would normally have just fixed them). Let's hold off actually fixing this stuff until we get feedback on doing it at all.
I put a note in the issue summary.
why is the rename of ConditionPluginBag not using the ..Lazy.. pattern like other rename?
this needs to be wrapped to 80 chars.
but the previous patch in #4 did this...
So I think there are some changes from #4 that might have been missed in this one... ?
typo in collectionss
this needs 80 char wrap also.
I wonder why this change in this issue? why not @see FilterBase::$filterCollection ... maybe because there is no filterBag property anyway... so instead of search and replace, just taking out the wrong @see. OK.
or... it was referring to FilterBase::$bag which is now $collection.
Noting for now, for later thinking.
needs 80 char wrap again.
80 chars.
Also, xjm reminded me, that git diff --colorwords is helpful in situations like these.
Comment #13
pwolanin commentedI think the naming currently is a total Drupal WTF, so I think this renaming would be a big DX win
Comment #14
fabianx commentedIf we want core committer feedback, RTBC is the status to use.
@Core committers - Just some nits left.
Trying with alexpott for now.
Can we get approval / disproval of this issue before fixing them?
Comment #15
catchThis is a tricky one for beta criteria, my personal opinion, not a 'decision' yet - let's see what others think.
1. The name is misleading rather than not ideal - i.e. there's tangible benefit in it expressing what it is, whereas it currently expresses what it's not.
On a hierarchy of renames: Accuracy > Precision > Aesthetics.
2. Not saying we should, but presumably the old class could be left in, unused, subclassing, with the old name for bc?
3. This was RTBC during DrupalCon Amsterdam, which #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase? has a section that would allow a little more leeway to those specific patches during the next 3.5 weeks, but that's not been discussed with Dries or webchick yet (was only posted 36 hours ago). Even if we do that, we could still decide the change isn't worth it, but it does mean it's OK to specifically ask for committer feedback here. Leaving assigned to Alex.
Comment #16
alexpottI'm okay with going forward with this under the "Amsterdam exception" rules.
So now to fix up the nits that @Fabianx refers to in #14
Also lets have a change record for the issue to help people.
Comment #17
cilefen commentedI started the draft change record: https://www.drupal.org/node/2352673
Comment #18
cilefen commentedComment #19
cilefen commentedComment #20
dawehner+1 for naming it lazy, because it tells you what happens. Yes, you could argue that this is an internal detail,
but on the other hand, people might realize what it is good for.
Comment #21
cilefen commentedThere are other classes renamed with suffix "Bag" that may be wrong in the current patch:
Should those be renamed that way?
Comment #22
mpdonadioFixed a bad wrap on a @todo.
Generated with `git diff -M10% --minimal 8.0.x`
Comment #23
alexpottComment #24
wim leersI discovered this through the change record draft (which again appeared in the feed of *published* change records, and therefore is broken again…).
This name is so much better, together with reading the change record I now *finally* fully understand what this "PluginBag" thing is about!
Comment #25
yesct commented@Wim Leers I went to make a comment on #2337375: Feed showing draft change records
but I could not see this draft record in
https://www.drupal.org/list-changes/drupal
or the rss feed, or the twitter feed for @drupal8changes
any thoughts on #21 ? Should we carry through the lazy wording on more class names?
taking off the needs change record tag since we have a draft and it looked good to @Wim Leers
Comment #26
wim leers#25: commented at #2337375-5: Feed showing draft change records.
Comment #27
cilefen commentedReroll.
Comment #28
cilefen commentedRegarding #21, I think we should not include Lazy in the names of the classes that extend LazyPluginCollection, except for DefaultLazyPluginCollection DefaultSingleLazyPluginCollection.
ActionBag should probably be renamed to ActionPluginCollection and similarly for the rest.
Comment #29
yesct commented@cilefen ok. since lazy can be argued to be an implementation detail, that seems ok to me. (and I can't get a strong response from others.)
Comment #30
yesct commentedneeds work to do #28
Comment #31
cilefen commentedComment #32
cilefen commentedRerolled because of a comment change in #2235363: Document config dependencies.
Comment #33
mpdonadioFor reference (and before I lose this), here are two class hierarchies in question:
I am going to remove Lazy from ConditionLazyPluginCollection, and change to FooPluginCollection for the other leaf classes.
Comment #34
mpdonadioOK, renamed classes via refactor tools in PHPStorm. The new hierarchy is shown in the image.
Comment #35
cilefen commented@mpdonadio: this patch will be smaller and easier to read if you make it with
git diff -M10% --minimalComment #37
mpdonadioMinimal patch.
Comment #41
mpdonadioI missed two classes uses as strings for test mocks. Fixed those and they pass locally, along with a comment that was too long.
Comment #42
yesct commentedadded a before and after hierarchy to the summary.
Comment #43
yesct commentedupdated the change record with the rename details.
useful for reviewing:
on both head and with the patch
ag --ignore-case " bag" core/lib/* core/modules/*
ag --ignore-case "bag " core/lib/* core/modules/*
ag --ignore-case "pluginbag" core/lib/* core/modules/*
with the patch applied, useful for reviewing:
git diff --color-words -M10% --minimal 8.0.x
--
added to the summary
EntityWithPluginBagsInterface -> EntityWithPluginCollectionInterface
ConfigEntityBaseWithPluginBags -> ConfigEntityBaseWithPluginCollections
SearchPluginBagTest -> SearchPluginCollectionTest
and updated the change record again.
I read through the whole patch again. Looks ok to me.
Comment #44
mpdonadioShould we make the class names fully qualified in the Change Record?
Comment #45
alexpottCommitted 22c8258 and pushed to 8.0.x. Thanks!
I think fully qualified classnames will make the CR harder to read.