Problem/Motivation

We have:

  1. HtmlResponse + \Drupal\Core\EventSubscriber\HtmlResponseSubscriber + \Drupal\Core\Render\HtmlResponseAttachmentsProcessor
  2. AjaxResponse + \Drupal\Core\EventSubscriber\AjaxResponseSubscriber + \Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor

In both of those cases, the response contains the actual data, but some post-processing is necessary to render the final response.

ResourceResponse is similar: it contains the actual data, but needs some post-processing (serialization!) to render the final response.

Proposed resolution

  1. Introduce ResourceResponseSubscriber to serialize ResourceResponseInterface objects.
  2. Remove \Drupal\rest\RequestHandler::renderResponse().
  3. Figure out a way for retaining BC: ResourceInterface plugins are sadly still allowed to return plain Response, because that's how D8.0 shipped. We could do something with request attributes, or response headers, to let ResourceResponseSubscriber also detect resource responses that don't implement ResourceResponseInterface.

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

Wim Leers created an issue. See original summary.