Problem/Motivation
This is a child issue of #2352155: Remove HtmlFragment/HtmlPage. Hence this is a critical task.
A big part of #2352155: Remove HtmlFragment/HtmlPage is making the render pipeline more understandable. Typically, Drupal renders the main content into HTML (format: html). But as part of WSCCI, Drupal 8 gained the ability to negotiate to a specific (HTTP parlance) Content-Type (in Symfony Request parlance: a request format).
So we must ensure that the part of the pipeline that takes the main content and turns it into a Response is understandable not only for html, but also for drupal_ajax, drupal_dialog and drupal_modal — which are the other supported formats.
Proposed resolution
I believe that as part of that, it'd be great if we would merge AjaxResponseRenderer into AjaxController, because:
AjaxControlleris the only code that uses@ajax_response_rendererservice at allAjaxResponseRendereris already tightly coupled to it anyway- together with the other changes in #2352155, this will make
AjaxControllercontain/show the entire "main content ->Response" pipeline fordrupal_ajaxrequests, aiding understandability
Remaining tasks
Review.
User interface changes
None.
API changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | rm_ajax_response_renderer-2364127-10.patch | 1.48 KB | lussoluca |
Comments
Comment #1
wim leersComment #2
dawehnerIt's hard to describe what I want to answer here.
First, as you wrote in the IS, this is not a real requirement to get the critical fixed. Having a class which does the actual logic,
and one class which is just a wrapper is not a bad thing at all. That concept is called separation of concern.
It's not clear why this is hard to understand (you have the exact class in that file), but in case it is, you have huge problems in Drupal 8.
If we move this into the AjaxController, there is no way to reuse the rendering logic, this is a pain. We accidentally removed
a lot of API in Drupal 8 as it got moved to protected methods on controllers, of wait, you have done this here :)
Comment #3
wim leersI agree with the general things you say. But in this specific case, they don't apply, I think, precisely because
AjaxResponseRenderereffectively can only be used byAjaxControlleranyway.The actual rendering of
AjaxResponses happens inAjaxResponse::prepare(). That's why I think it's fine to mergeAjaxResponseRendererintoAjaxController.Comment #4
wim leersComment #5
fabianx commentedFor me this is RTBC, will track down Daniel to see if he agrees, but this is not critical, but a major to have - given the diagram.
We added around 20 loc of which around 10 loc will be removed due to special cases going away.
But in turn we removed around 30-40 loc of boilerplate, which really is too specific to have a use somewhere else.
If I wanted my own ajax renderer, I would subclass ajax_controller service anyway and even if I need to replace the ::content method, its only 10 loc to copy and likely I might even call the parent()::content() method anyway, then alter it.
Therefore => clear win!
Comment #6
dawehnerWell whatever.
Comment #7
wim leersComment #8
alexpottCommitted 40db9b9 and pushed to 8.0.x. Thanks!
Comment #10
lussolucaI get a fatal error:
because the patch removes the third argument from the view_subscriber but not from the ViewSubscriber class
Comment #11
wim leersHuh, wow, what!?!? That hunk should definitely have been in my patch also, and I'd swear it was… How the hell did my patch even pass testing then?
What a mess — sorry about this!
Thanks for the patch, lussoluca!
Comment #12
alexpottGiven #10 we must be missing test coverage. Also I will no longer commit on issue followups. Please open a new issue. Why? Because this is a bug and the original issue was task so we can not manage and maintain the issue metadata correctly. See you in the new issue.
Comment #13
mile23Would really love to know if there was ever another followup issue. I made this one: #2366645: Drupal\Tests\Core\Controller\AjaxControllerTest has wrong @covers.
Comment #14
alexpottAfaik no followup for #10 has been created.
Comment #15
lussolucaFollowup here: #2366757: Fatal error on ViewSubscriber