Blocked by #2256365: Factor render->fragment code out to a service
Problem/Motivation
We have a confusing double-architecture right now with "wrapping controllers" -- based on the mime type of a request and the type of _-property that was used in a route definition -- and View listeners, that can look at the same information to determine what to do with an HtmlFragment object in what circumstances. So let's fix that and standardize on the latter.
Proposed resolution
* Add another listener method to HtmlViewSubscriber that runs before the existing listeners.
* That listener looks for a controller response that is an array; it assumes that it is a render array and uses the RenderHtmlRenderer service to turn it into an HtmlFragment. Then save it back to the event so that the rest of the pipeline can work as it already does.
* Debatable: Also check for strings, turn those into a render array, and then do the above. (Alternatively, do the string handling inside RenderHtmlRenderer.)
* Eliminate HtmlPageController entirely as it will no longer be necessary.
* Instead of wrapping HtmlPageController around _content-using routes, convert the _content to a _controller.
Remaining tasks
Do it.
User interface changes
None.
API changes
_content becomes vestigial for pages. _controller routes, actually, would implicitly be able to return strings or arrays and get the same handling as if they were _content (See #2092647: Consolidate _form, _controller, _entity_form, etc. into just _controller?). Long-term we can deprecate and remove _content, but for BC reasons that will not happen within 8.x.
Comment | File | Size | Author |
---|---|---|---|
#9 | controller-render-2334229-9.patch | 11.21 KB | kgoel |
#7 | controller-render-2334229-7.patch | 10.86 KB | kgoel |
#5 | controller-render-2334229-5.patch | 10.89 KB | kgoel |
#3 | interdiff.txt | 4.79 KB | kgoel |
#3 | controller-render-2334229-3.patch | 5.56 KB | kgoel |
Comments
Comment #1
Crell CreditAttribution: Crell commentedComment #2
kgoel CreditAttribution: kgoel commentedI have addressed first two proposed solution and going to address rest later today. This is just to see if test bot likes this patch.
Comment #3
kgoel CreditAttribution: kgoel commentedAddressed rest of the proposed resolutions except - Instead of wrapping HtmlPageController around _content-using routes, convert the _content to a _controller because of API change.
Comment #5
kgoel CreditAttribution: kgoel commentedComment #7
kgoel CreditAttribution: kgoel commentedComment #9
kgoel CreditAttribution: kgoel commentedComment #11
Crell CreditAttribution: Crell commentedI'm unclear on the point of this trait.
If making a trait like this, don't rely on properties being defined properly. You can't guarantee what the using class will do. Instead, get these services via a protected abstract method. Then it's the using class's responsibility to get access to those services and expose them via those methods.
This trait doesn't technically no from controllers. Just "If the content is already a fragment or a response there is no work to do."
The $renderer = line seems unused.
It looks like a lot of the test fails are fatal errors, which means they should be easy to replicate manually in the UI for debugging.
Comment #12
jibranComment #13
kgoel CreditAttribution: kgoel commentedI am not sure if any work needed on this issue since https://www.drupal.org/node/2327277 is postponed and https://www.drupal.org/node/2352155?
Comment #14
kgoel CreditAttribution: kgoel commentedMarking it as postponed
Comment #15
catchYes marking duplicate of #2352155: Remove HtmlFragment/HtmlPage.