We currently have a new Display() method on our ViewExecutable class. This seems fine at first, but then look at the storage class. We also have a newDisplay() method on there which calls addDisplay to get a new id to use then passes this to the newDisplay method on the ViewExecutable. So this method doesn't create a new display at all but just creates an instance from storage.
I vote that we change the name of this method, as well as the docs, which currently start with "Creates and stores a new display.", or, do we even still need this method at all? #1817582: Lazy load display plugins will affect what goes on here I think. Looking at that patch, I think if a new display is added we also need to update the displayIDs property on DisplayArray?
Comment | File | Size | Author |
---|---|---|---|
#31 | drupal-1867304-30.patch | 8.6 KB | damiankloip |
#30 | drupal-1867304-30.patch | 0 bytes | damiankloip |
#30 | interdiff.txt | 2.12 KB | damiankloip |
#29 | drupal-1867304-29.patch | 10.28 KB | damiankloip |
#29 | interdiff.txt | 1.88 KB | damiankloip |
Comments
Comment #1
damiankloip CreditAttribution: damiankloip commentedComment #2
damiankloip CreditAttribution: damiankloip commentedSo maybe removing newDisplay on ViewExecutable could be an option and just let display array create the instance?
Comment #3
dawehnernewDisplayInstance maybe?
Comment #4
damiankloip CreditAttribution: damiankloip commentedReally, now we have the DisplayArray class to manage our display instances, we don't really need newDisplay on the ViewExecutable. We can create our instance without it. It also saves the displays back to storage but doesn't change anything. So it's a bit broken anyway!
Here is a patch that removes newDisplay as it's only called by newDisplay on the View storage. I have also added some new methods to DisplayArray to access the displayIDs. Thoughts?
Comment #6
damiankloip CreditAttribution: damiankloip commentedPostponing on #1869566: Allow any collection of plugins to be lazily instantiated for now, these methods can move onto there anyway.
Comment #7
dawehnerRebased against #1869566: Allow any collection of plugins to be lazily instantiated
Comment #8
dawehnerWell ...
Comment #9
damiankloip CreditAttribution: damiankloip commentedIsn't that that same, just rebased against the changes from #1850792: Make init() method consistent across all views plugins?
Comment #10
dawehnerYeah exactly.
Comment #11
dawehnerI'm wondering whether we could do this lazy aka only add the display ID if an executable actually exists..., because if you initialize it later, you will not have problems.
So this never actually stored anything on the storage, this seems to be a bug in the old code :)
Comment #12
damiankloip CreditAttribution: damiankloip commentedThat sounds like a good plan to me, let's work on that once this is unpostponed and the lazy loading patch is in.
Comment #13
damiankloip CreditAttribution: damiankloip commentedHere is a new patch based on the #1869566: Allow any collection of plugins to be lazily instantiated patch that just went in.
I have added the methods that were on DisplayArray previously to the PluginBag class, do we need these here? I vote yes anyway.
Comment #14
damiankloip CreditAttribution: damiankloip commentedComment #15
dawehnerIn general I'm wondering whether the ::set() method should call addInstanceID?
Is the fix a proper one?
Comment #16
dawehnerThis doesn't help, because the get method always instanciats an executable, so we should better check for if ($executable = $this->executable); Maybe we should also document this few lines.
Comment #17
damiankloip CreditAttribution: damiankloip commentedYeah, that's a good point! I forgot we were doing that in get(). If we change this we also have to change the tests a bit too. What do you think?
The interdiff is slightly out of date, I amended a couple of docs (minor) too.
Comment #19
tim.plunkett#17: 1867304-17.patch queued for re-testing.
Comment #20
dawehnerThis looks really good already!
Should set() call addInstanceID?
That's a good improvement in terms of readability of the patch.
Seems unneeded but I don't care.
Comment #22
damiankloip CreditAttribution: damiankloip commentedYeah, I guess it does make sense to also add the instanceID in set() too.
I also removed that destroy call. More of a habit than anything :)
Comment #23
dawehnerAwesome
Comment #25
dawehnerLet's fix the test failures.
Comment #27
dawehner#25: drupal-1867304-25.patch queued for re-testing.
Comment #29
damiankloip CreditAttribution: damiankloip commentedNow that we are adding to the instanceIDs array too (which we should have been to start with I think but meh) we need to unset it from here too so we don't get the pluginBag trying to create an instance.
So we need a couple of tests for this too, to check they are removed from the instanceIDs array. See interdiff.
Comment #30
damiankloip CreditAttribution: damiankloip commentedOk, spoke to Tim on IRC. His thoughts are we should not be modifying instanceIDs when we add/remove instances. So here is basically an earlier patch, let's see how we get on.
Comment #31
damiankloip CreditAttribution: damiankloip commentedSorry, and a real patch to boot.
Comment #32
tim.plunkettThis looks like a good API improvement.
Comment #33
damiankloip CreditAttribution: damiankloip commentedI think #1876942: Use direct methods instead of arrayAccess for display handlers should now be waiting on this too.
Comment #34
webchickCommitted and pushed to 8.x. Thanks!