You are here

protected function RequestHandler::prepareResponse in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::prepareResponse()

Prepares the REST resource response.

Parameters

\Drupal\rest\ResourceResponseInterface $response: The REST resource response.

\Drupal\rest\RestResourceConfigInterface $resource_config: The REST resource config entity.

Return value

\Drupal\rest\ResourceResponseInterface The prepared REST resource response.

2 calls to RequestHandler::prepareResponse()
RequestHandler::handle in core/modules/rest/src/RequestHandler.php
Handles a REST API request.
RequestHandler::handleRaw in core/modules/rest/src/RequestHandler.php
Handles a REST API request without deserializing the request body.

File

core/modules/rest/src/RequestHandler.php, line 102

Class

RequestHandler
Acts as intermediate request forwarder for resource plugins.

Namespace

Drupal\rest

Code

protected function prepareResponse($response, RestResourceConfigInterface $resource_config) {
  if ($response instanceof CacheableResponseInterface) {
    $response
      ->addCacheableDependency($resource_config);
  }
  return $response;
}