class ResourceResponse in Drupal 9
Same name in this branch
- 9 core/modules/jsonapi/src/ResourceResponse.php \Drupal\jsonapi\ResourceResponse
- 9 core/modules/rest/src/ResourceResponse.php \Drupal\rest\ResourceResponse
Same name and namespace in other branches
- 8 core/modules/rest/src/ResourceResponse.php \Drupal\rest\ResourceResponse
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.
Hierarchy
- class \Drupal\rest\ResourceResponse extends \Symfony\Component\HttpFoundation\Response implements CacheableResponseInterface, ResourceResponseInterface uses CacheableResponseTrait, ResourceResponseTrait
Expanded class hierarchy of ResourceResponse
See also
\Drupal\rest\ModifiedResourceResponse
6 files declare their use of ResourceResponse
- DBLogResource.php in core/
modules/ dblog/ src/ Plugin/ rest/ resource/ DBLogResource.php - EntityResource.php in core/
modules/ rest/ src/ Plugin/ rest/ resource/ EntityResource.php - NoSerializationClassTestResource.php in core/
modules/ rest/ tests/ modules/ rest_test/ src/ Plugin/ rest/ resource/ NoSerializationClassTestResource.php - RequestHandlerTest.php in core/
modules/ rest/ tests/ src/ Kernel/ RequestHandlerTest.php - ResourceResponseSubscriberTest.php in core/
modules/ rest/ tests/ src/ Unit/ EventSubscriber/ ResourceResponseSubscriberTest.php
File
- core/
modules/ rest/ src/ ResourceResponse.php, line 19
Namespace
Drupal\restView source
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableResponseTrait:: |
protected | property | The cacheability metadata. | |
CacheableResponseTrait:: |
public | function | ||
CacheableResponseTrait:: |
public | function | ||
ResourceResponse:: |
public | function | Constructor for ResourceResponse objects. | |
ResourceResponseTrait:: |
protected | property | Response data that should be serialized. | |
ResourceResponseTrait:: |
public | function | Returns response data that should be serialized. |