ResourceResponse.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Drupal\rest;
  3. use Drupal\Core\Cache\CacheableResponseInterface;
  4. use Drupal\Core\Cache\CacheableResponseTrait;
  5. use Symfony\Component\HttpFoundation\Response;
  6. /**
  7. * Contains data for serialization before sending the response.
  8. *
  9. * We do not want to abuse the $content property on the Response class to store
  10. * our response data. $content implies that the provided data must either be a
  11. * string or an object with a __toString() method, which is not a requirement
  12. * for data used here.
  13. *
  14. * @see \Drupal\rest\ModifiedResourceResponse
  15. */
  16. class ResourceResponse extends Response implements CacheableResponseInterface, ResourceResponseInterface {
  17. use CacheableResponseTrait;
  18. use ResourceResponseTrait;
  19. /**
  20. * Constructor for ResourceResponse objects.
  21. *
  22. * @param mixed $data
  23. * Response data that should be serialized.
  24. * @param int $status
  25. * The response status code.
  26. * @param array $headers
  27. * An array of response headers.
  28. */
  29. public function __construct($data = NULL, $status = 200, $headers = []) {
  30. $this->responseData = $data;
  31. parent::__construct('', $status, $headers);
  32. }
  33. }