Mercurial > hg > cmmr2012-drupal-site
diff core/modules/rest/src/ResourceResponse.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/rest/src/ResourceResponse.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,39 @@ +<?php + +namespace Drupal\rest; + +use Drupal\Core\Cache\CacheableResponseInterface; +use Drupal\Core\Cache\CacheableResponseTrait; +use Symfony\Component\HttpFoundation\Response; + +/** + * Contains data for serialization before sending the response. + * + * We do not want to abuse the $content property on the Response class to store + * our response data. $content implies that the provided data must either be a + * string or an object with a __toString() method, which is not a requirement + * for data used here. + * + * @see \Drupal\rest\ModifiedResourceResponse + */ +class ResourceResponse extends Response implements CacheableResponseInterface, ResourceResponseInterface { + + use CacheableResponseTrait; + use ResourceResponseTrait; + + /** + * Constructor for ResourceResponse objects. + * + * @param mixed $data + * Response data that should be serialized. + * @param int $status + * The response status code. + * @param array $headers + * An array of response headers. + */ + public function __construct($data = NULL, $status = 200, $headers = []) { + $this->responseData = $data; + parent::__construct('', $status, $headers); + } + +}