5 use Drupal\Core\Cache\CacheableResponseInterface;
6 use Drupal\Core\Cache\CacheableResponseTrait;
7 use Symfony\Component\HttpFoundation\Response;
10 * Contains data for serialization before sending the response.
12 * We do not want to abuse the $content property on the Response class to store
13 * our response data. $content implies that the provided data must either be a
14 * string or an object with a __toString() method, which is not a requirement
17 * @see \Drupal\rest\ModifiedResourceResponse
19 class ResourceResponse extends Response implements CacheableResponseInterface, ResourceResponseInterface {
21 use CacheableResponseTrait;
22 use ResourceResponseTrait;
25 * Constructor for ResourceResponse objects.
28 * Response data that should be serialized.
30 * The response status code.
31 * @param array $headers
32 * An array of response headers.
34 public function __construct($data = NULL, $status = 200, $headers = []) {
35 $this->responseData = $data;
36 parent::__construct('', $status, $headers);