Service to standardize building response objects for API requests.
Definition at line 13 of file MetastoreApiResponse.php.
◆ __construct()
Constructor.
- Parameters
-
\Drupal\metastore\Factory\MetastoreItemFactoryInterface | $metastoreItemFactory | Metastore Item factory service. |
Definition at line 21 of file MetastoreApiResponse.php.
◆ addReferenceDependencies()
Drupal\metastore\MetastoreApiResponse::addReferenceDependencies |
( |
CacheableMetadata |
$cacheMetadata, |
|
|
MetastoreItemInterface |
$item |
|
) |
| |
|
protected |
Add more dependencies for a metastore item's references.
- Parameters
-
\Drupal\Core\Cache\CacheableMetadata | $cacheMetadata | Cache metadata object. |
\Drupal\metastore\MetastoreItemInterface | $item | Metastore item, such as a dataset. |
Definition at line 131 of file MetastoreApiResponse.php.
◆ cachedJsonResponse()
Drupal\metastore\MetastoreApiResponse::cachedJsonResponse |
( |
|
$data, |
|
|
int |
$code = 200 , |
|
|
array |
$dependencies = [] , |
|
|
?ParameterBag |
$params = NULL |
|
) |
| |
Create a basic, cacheable JSON response.
- Parameters
-
mixed | $data | Array or object that can be encoded as JSON. |
int | $code | An HTTP response code. |
array | $dependencies | Cacheable dependencies for the response that will be used for tagging. Should be an array of arrays of metastore IDs, keyed by schema type. For instance, ['dataset' => ['5160a9f1-ee5d-4e94-ab53-183104e2ef4b']]. If you want to add a general schema tag – for instance, for a route that lists all items of a particular schema, simply add that schema to the array as a string. For instance, ['dataset']. |
\Symfony\Component\HttpFoundation\ParameterBag | null | $params | The parameter object from the request. |
- Returns
- \Drupal\Core\Cache\CacheableJsonResponse A response, ready to be returned to a route.
Definition at line 45 of file MetastoreApiResponse.php.
◆ getMetastoreItemFactory()
Drupal\metastore\MetastoreApiResponse::getMetastoreItemFactory |
( |
| ) |
|
|
protected |
Return the metastore item factory service.
- Returns
- \Drupal\metastore\Factory\MetastoreItemFactoryInterface Metastore item factory.
Definition at line 187 of file MetastoreApiResponse.php.