function RequestHandler::prepareResponse

Same name in other branches
  1. 9 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::prepareResponse()
  2. 8.9.x core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::prepareResponse()
  3. 10 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.