Closed (fixed)
Project:
Panels
Version:
8.x-3.x-dev
Component:
Plugins - display renderers
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 Sep 2014 at 19:11 UTC
Updated:
6 Nov 2015 at 01:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
dsnopekComment #2
mglamanHere's a WIP which defines the annotation plugin and some interfaces. I think the next best step would be to decorate the interface and move from there.
Comment #3
mglamanHere is actually an initial shot - this new patch defines the Standard, Simple, and Editor plugins. It includes an abstract base plugins can extend. The renderer just has a __construct and render() interface requirement. My take on it is that renderers will use internal methods to manipulate the layout plugin, which current handles building its regions and invoking the theme system.
Comment #4
dsnopek@mglaman: Thanks for picking this up! All the boilerplate looks good, this is a good start. :-)
However, I think architecturally the model is inverted. IMO, the Renderer's job is to prepare the content of the regions before they go to the Layout. So, DisplayVariant asks the Renderer to prepare the regions and then passes those regions to the Layout plugin. Whereas the current patch has the Renderer asking the DisplayVariant to render the page. So, we need to flip this around!
This way, the standard (and base) renderer would just apply region and block styles. But the IPE renderer would add the extra markup/Javascript necessary to do the in-place editing. And the editor renderer would add the extra buttons/drop-downs/etc to each region/pane that would be used in Page Manager (theoretically, I'm not sure how we'll actually do this in real life, but this is the general idea).
However, I'm not sure if "before the regions go to the Layout" should mean either (a) before we call
$layout->build()or (b) before the layout theme function renders the whole thing. I could see an argument for either one...Also, and this is a super minor thing:
Let's call this function build(). There's a sort of convention in D8 that you call creating a render array building, because the actual rendering is done by later.
Feel free to ping me on IRC if you want to discuss this in a higher-bandwidth way!
Comment #5
saltednutThis patch addresses the concerns in #4 above, moving the logic around so that DisplayVariant is asking the DisplayRenderer to render the page.
We're now providing the DisplayRenderer the ability to process the regions before the layout, and one chooses renderer (e.g. Standard) when choosing the display variant's layout via the form.
Comment #6
saltednutComment #7
dsnopek@brantwynn: Thanks, this is looking really good! All my review from #4 is addressed.
Here's some new review! The first several items are quick fix, nit-picky stuff which should be easy to take care of right away. Then the last few items are deeper architectural things that we might need to hammer on for a bit.
Shouldn't have .php
Let's renamed this to 'label' to match layout plugins
This should just be {@inheritdoc}
Incorrect class name and namespace
This isn't exactly true for Drupal 8, and needs to be updated, however...
PanelsDisplayVariant::buildRegions()needs to get moved into either the standard renderer or theDisplayRendererBasebecause in Drupal 7 it's actually the renderer that's responsible for constructing the render array out of the list of configured blocks AND for applying the layout In general, I think we need a pass at making sure we're using renders the same way in D8 as we are in D7.Comment #8
saltednutThis patch addresses points 1 through 6 of comment #7.
Re 7.7: We may need to do some more refactoring, so I didn't rename anything yet.
Re 7.8: I would recommend we file a followup because working on the "editor" is going to be a bigger task that might actually be best served as a meta issue with multiple sub-issues around using it to render the admin form, making it functional, etc.
In this patch, I am also removing the 'simple' renderer until we can figure out why it existed in D7 and whether or not we actually need it in D8.
Comment #9
saltednutThere were some docblock issues with either missing phpdoc or the wrong declaration for @param looking for ContextAwarePluginInterface instead of the correct ContextHandlerInterface
Comment #10
dsnopek@brantwynn: Awesome, thanks! This is looking really great, and I think we're super close. :-)
At the sprint yesterday, @Crell taught me how to inject services into plugins (it is possisble!) so here is a new version of the patch which does that and performs a little clean-up.
The patch is working great in my manual testing!
Comment #11
dsnopekA little more review:
Let's rename this to EditorDisplayBuilder. All the other plugin types repeat the name of the of the plugin in the class name.
And this to StandardDisplayBuilder
Oops! This was something I forgot got to do in the last patch. This should use the injected $this->rendererManager (or, actually, $this->builderManager after the rename) rather than calling \Drupal::service() directly.
Thanks!
Comment #12
dsnopekOh, and it's Drupal coding standards (I think?) to capitalize NULL
Here too!
Comment #13
dsnopekHiding super old patch...
Comment #14
dsnopekHere is a new patch that makes all the changes I requested in #11 and #12. No interdiff because this renames all the files.
And here is a new issue to use the 'editor' display builder in the admin interface: #2553507: Use the 'editor' display builder for admin form
Comment #15
saltednutThis is looking really good from my manual testing. @dsnopek thanks for pushing this through and showing me what was up along the way. Hopefully we can get a maintainer in here to review soon.
Comment #16
tim.plunkettThis is broken without contextHandler.
Comment #17
saltednutIn an attempt to return the context handler I am seeing:
Comment #18
saltednutI maybe missed some code that was not supposed to be deleted.
Comment #19
tim.plunkettThis needs tests, because that was seriously broken
Comment #20
dsnopekThanks @tim.plunkett for tracking this down and @brantwynn for the new patch!
We definitely need tests in Panels in general, and I think it totally makes sense to write some tests for the new display builder code.
I'd be reluctant to write tests for the PanelsDisplayVariant at this point, though, since it still contains copy-pasted code from Page Manager which will be eliminated after we finish moving the necessary code to CTools (per #2511554: [meta] Move some parts of Page Manager into CTools) and then do #2511582: Extend BlockDisplayVariant rather than copying code from Page Manager.
Eventually PanelsDisplayVariant will descend from a variant base class which is basically the same as Page Manager's BlockDisplayVariant (except living in CTools) and we can rely on its tests for all that functionality, and then in Panels we only have to test the bits that we overrode. If we wrote tests for it now, we'd probably just throw them all away once the refactor is finished (or end up copy-pasting tests from Page Manage too - but let's just not do that).
However, this mistake was in PanelsDisplayVariant. :-)
Comment #21
saltednutOh yeah, sorry @tim.plunkett I meant to mention that it was totally broken. I posted #18 because I was stuck. Tests would definitely help.
Comment #22
saltednutComment #23
mpotter commentedHere is a re-rolled patch against the latest dev. I tested creating a Panels page variant and added a block and it seemed to work, but more testing and eyes are needed. And as mentioned in #19 this definitely needs some tests to be written. Maybe a separate issue for the tests so we can commit this soon since it blocks other work?
Comment #24
phenaproximaComment #26
phenaproximaMade some minor style/wording changes...
Comment #27
phenaproximaEr...forgot the interdiff.
Comment #28
phenaproxima@mpotter's patch was awesome and made it possible to write a simple unit test of StandardDisplayBuilder. Nice.
Comment #29
phenaproximaJust noticed...this should be PanelsDisplayVariant. Can be fixed on commit, though...
Comment #30
phenaproximaRenamed AdminDisplayBuilder back to EditorDisplayBuilder and fixed #29.
Comment #31
dsnopekLooks good to me! And it worked for me with manual testing. RTBC!
Comment #35
japerryAlso worked good for me!