You are here

protected function ResourceBase::createJsonapiResponse in JSON:API Resources 8

Builds a response with the appropriate wrapped document.

Parameters

\Drupal\jsonapi\JsonApiResource\ResourceObjectData $data: The data to wrap.

\Symfony\Component\HttpFoundation\Request $request: The request object.

int $response_code: The response code.

array $headers: An array of response headers.

\Drupal\jsonapi\JsonApiResource\LinkCollection $links: The URLs to which to link. A 'self' link is added automatically.

array $meta: (optional) The top-level metadata.

Return value

\Drupal\jsonapi\ResourceResponse The response.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

3 calls to ResourceBase::createJsonapiResponse()
AuthorArticles::process in tests/modules/jsonapi_resources_test/src/Resource/AuthorArticles.php
Process the resource request.
CurrentUserInfo::process in tests/modules/jsonapi_resources_test/src/Resource/CurrentUserInfo.php
Process the resource request.
FeaturedNodes::process in tests/modules/jsonapi_resources_test/src/Resource/FeaturedNodes.php
Process the resource request.

File

src/Resource/ResourceBase.php, line 107

Class

ResourceBase
Defines basic functionality for a JSON:API Resource.

Namespace

Drupal\jsonapi_resources\Resource

Code

protected function createJsonapiResponse(ResourceObjectData $data, Request $request, $response_code = 200, array $headers = [], LinkCollection $links = NULL, array $meta = []) : ResourceResponse {
  return $this->resourceResponseFactory
    ->create($data, $request, $response_code, $headers, $links, $meta);
}