class CacheableResourceResponse in Drupal 9
Extends ResourceResponse with cacheability.
We want to have the same functionality for both responses that are cacheable and those that are not. This response class should be used in all instances where the response is expected to be cacheable.
@internal JSON:API maintains no PHP API since its API is the HTTP API. This class may change at any time and this will break any dependencies on it.
Hierarchy
- class \Drupal\jsonapi\ResourceResponse extends \Symfony\Component\HttpFoundation\Response
- class \Drupal\jsonapi\CacheableResourceResponse implements CacheableResponseInterface uses CacheableResponseTrait
Expanded class hierarchy of CacheableResourceResponse
See also
https://www.drupal.org/project/drupal/issues/3032787
6 files declare their use of CacheableResourceResponse
- DefaultExceptionSubscriber.php in core/
modules/ jsonapi/ src/ EventSubscriber/ DefaultExceptionSubscriber.php - EntityResource.php in core/
modules/ jsonapi/ src/ Controller/ EntityResource.php - EntityResourceTest.php in core/
modules/ jsonapi/ tests/ src/ Kernel/ Controller/ EntityResourceTest.php - EntryPoint.php in core/
modules/ jsonapi/ src/ Controller/ EntryPoint.php - ResourceResponseTestTrait.php in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceResponseTestTrait.php
File
- core/
modules/ jsonapi/ src/ CacheableResourceResponse.php, line 21
Namespace
Drupal\jsonapiView source
class CacheableResourceResponse extends ResourceResponse implements CacheableResponseInterface {
use CacheableResponseTrait;
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableResponseTrait:: |
protected | property | The cacheability metadata. | |
CacheableResponseTrait:: |
public | function | ||
CacheableResponseTrait:: |
public | function | ||
ResourceResponse:: |
protected | property | Response data that should be serialized. | |
ResourceResponse:: |
public | function | Returns response data that should be serialized. | |
ResourceResponse:: |
public | function | Constructor for ResourceResponse objects. |