You are here

protected function RequestHandler::delegateToRestResourcePlugin in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::delegateToRestResourcePlugin()

Delegates an incoming request to the appropriate REST resource plugin.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.

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

mixed|null $unserialized: The unserialized request body, if any.

\Drupal\rest\Plugin\ResourceInterface $resource: The REST resource plugin.

Return value

\Symfony\Component\HttpFoundation\Response|\Drupal\rest\ResourceResponseInterface The REST resource response.

2 calls to RequestHandler::delegateToRestResourcePlugin()
RequestHandler::handle in core/modules/rest/src/RequestHandler.php
Handles a REST API request.
RequestHandler::handleRaw in core/modules/rest/src/RequestHandler.php
Handles a REST API request without deserializing the request body.

File

core/modules/rest/src/RequestHandler.php, line 210

Class

RequestHandler
Acts as intermediate request forwarder for resource plugins.

Namespace

Drupal\rest

Code

protected function delegateToRestResourcePlugin(RouteMatchInterface $route_match, Request $request, $unserialized, ResourceInterface $resource) {
  $method = static::getNormalizedRequestMethod($route_match);

  // Determine the request parameters that should be passed to the resource
  // plugin.
  $argument_resolver = $this
    ->createArgumentResolver($route_match, $unserialized, $request);
  $arguments = $argument_resolver
    ->getArguments([
    $resource,
    $method,
  ]);

  // Invoke the operation on the resource plugin.
  return call_user_func_array([
    $resource,
    $method,
  ], $arguments);
}