You are here

private function ResourceResponseFactory::getIncludes in JSON:API Resources 8

Gets includes for the given response data.

Parameters

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

\Drupal\jsonapi\JsonApiResource\ResourceObject|\Drupal\jsonapi\JsonApiResource\ResourceObjectData $data: The response data from which to resolve includes.

Return value

\Drupal\jsonapi\JsonApiResource\IncludedData A Data object to be included or a NullData object if the request does not specify any include paths.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

1 call to ResourceResponseFactory::getIncludes()
ResourceResponseFactory::create in src/Unstable/ResourceResponseFactory.php
Builds a response with the appropriate wrapped document.

File

src/Unstable/ResourceResponseFactory.php, line 109

Class

ResourceResponseFactory
Creates JSON:API response objects.

Namespace

Drupal\jsonapi_resources\Unstable

Code

private function getIncludes(Request $request, $data) : IncludedData {
  assert($data instanceof ResourceObject || $data instanceof ResourceObjectData);
  return $request->query
    ->has('include') && ($include_parameter = $request->query
    ->get('include')) && !empty($include_parameter) ? $this->includeResolver
    ->resolve($data, $include_parameter) : new NullIncludedData();
}