Mercurial > hg > isophonics-drupal-site
annotate core/modules/rest/src/ResourceResponse.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 4c8ae668cc8c |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\rest; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Cache\CacheableResponseInterface; |
Chris@0 | 6 use Drupal\Core\Cache\CacheableResponseTrait; |
Chris@0 | 7 use Symfony\Component\HttpFoundation\Response; |
Chris@0 | 8 |
Chris@0 | 9 /** |
Chris@0 | 10 * Contains data for serialization before sending the response. |
Chris@0 | 11 * |
Chris@0 | 12 * We do not want to abuse the $content property on the Response class to store |
Chris@0 | 13 * our response data. $content implies that the provided data must either be a |
Chris@0 | 14 * string or an object with a __toString() method, which is not a requirement |
Chris@0 | 15 * for data used here. |
Chris@0 | 16 * |
Chris@0 | 17 * @see \Drupal\rest\ModifiedResourceResponse |
Chris@0 | 18 */ |
Chris@0 | 19 class ResourceResponse extends Response implements CacheableResponseInterface, ResourceResponseInterface { |
Chris@0 | 20 |
Chris@0 | 21 use CacheableResponseTrait; |
Chris@0 | 22 use ResourceResponseTrait; |
Chris@0 | 23 |
Chris@0 | 24 /** |
Chris@0 | 25 * Constructor for ResourceResponse objects. |
Chris@0 | 26 * |
Chris@0 | 27 * @param mixed $data |
Chris@0 | 28 * Response data that should be serialized. |
Chris@0 | 29 * @param int $status |
Chris@0 | 30 * The response status code. |
Chris@0 | 31 * @param array $headers |
Chris@0 | 32 * An array of response headers. |
Chris@0 | 33 */ |
Chris@0 | 34 public function __construct($data = NULL, $status = 200, $headers = []) { |
Chris@0 | 35 $this->responseData = $data; |
Chris@0 | 36 parent::__construct('', $status, $headers); |
Chris@0 | 37 } |
Chris@0 | 38 |
Chris@0 | 39 } |