function RequestHandler::delegateToRestResourcePlugin
Same name in other branches
- 9 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::delegateToRestResourcePlugin()
- 10 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::delegateToRestResourcePlugin()
- 11.x 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 227
Class
- RequestHandler
- Acts as intermediate request forwarder for resource plugins.
Namespace
Drupal\restCode
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);
try {
$arguments = $argument_resolver->getArguments([
$resource,
$method,
]);
} catch (\RuntimeException $exception) {
@trigger_error('Passing in arguments the legacy way is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Provide the right parameter names in the method, similar to controllers. See https://www.drupal.org/node/2894819', E_USER_DEPRECATED);
$arguments = $this->getLegacyParameters($route_match, $unserialized, $request);
}
// Invoke the operation on the resource plugin.
return call_user_func_array([
$resource,
$method,
], $arguments);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.