Open Data Catalog v2.0.0
Drupal\metastore\MetastoreApiResponse Class Reference

Public Member Functions

 __construct (MetastoreItemFactoryInterface $metastoreItemFactory)
 cachedJsonResponse ( $data, int $code=200, array $dependencies=[], ?ParameterBag $params=NULL)

Protected Member Functions

 addReferenceDependencies (CacheableMetadata $cacheMetadata, MetastoreItemInterface $item)
 getMetastoreItemFactory ()

Detailed Description

Service to standardize building response objects for API requests.

Definition at line 13 of file MetastoreApiResponse.php.

Constructor & Destructor Documentation

◆ __construct()

Drupal\metastore\MetastoreApiResponse::__construct ( MetastoreItemFactoryInterface  $metastoreItemFactory)


\Drupal\metastore\Factory\MetastoreItemFactoryInterface$metastoreItemFactoryMetastore Item factory service.

Definition at line 21 of file MetastoreApiResponse.php.

Member Function Documentation

◆ addReferenceDependencies()

Drupal\metastore\MetastoreApiResponse::addReferenceDependencies ( CacheableMetadata  $cacheMetadata,
MetastoreItemInterface  $item 

Add more dependencies for a metastore item's references.

\Drupal\Core\Cache\CacheableMetadata$cacheMetadataCache metadata object.
\Drupal\metastore\MetastoreItemInterface$itemMetastore 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.

mixed$dataArray or object that can be encoded as JSON.
int$codeAn HTTP response code.
array$dependenciesCacheable 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$paramsThe parameter object from the request.
\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 ( )

Return the metastore item factory service.

\Drupal\metastore\Factory\MetastoreItemFactoryInterface Metastore item factory.

Definition at line 187 of file MetastoreApiResponse.php.