You are here

protected function JsonapiResourceController::getJsonapiResource in JSON:API Resources 8

Loads a JSON:API Resource from route defaults.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $current_route: A matched route.

Return value

\Drupal\jsonapi_resources\Resource\ResourceBase The JSON:API resource that should be used for processing a request for the given route.

1 call to JsonapiResourceController::getJsonapiResource()
JsonapiResourceController::processRequest in src/Unstable/Controller/JsonapiResourceController.php
Processes a request and returns a JSON:API ResourceResponse.

File

src/Unstable/Controller/JsonapiResourceController.php, line 84

Class

JsonapiResourceController
An interstitial controller between raw requests & JSON:API resource objects.

Namespace

Drupal\jsonapi_resources\Unstable\Controller

Code

protected function getJsonapiResource(RouteMatchInterface $current_route) : ResourceBase {
  $definition = $current_route
    ->getRouteObject()
    ->getDefault('_jsonapi_resource');
  $resource = $this->classResolver
    ->getInstanceFromDefinition($definition);
  assert($resource instanceof ResourceBase);
  return $resource;
}