function RequestHandler::handle

Same name in other branches
  1. 8.9.x core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::handle()
  2. 10 core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::handle()
  3. 11.x core/modules/rest/src/RequestHandler.php \Drupal\rest\RequestHandler::handle()

Handles a REST API request.

Parameters

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

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

\Drupal\rest\RestResourceConfigInterface $_rest_resource_config: The REST resource config entity.

Return value

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

File

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

Class

RequestHandler
Acts as intermediate request forwarder for resource plugins.

Namespace

Drupal\rest

Code

public function handle(RouteMatchInterface $route_match, Request $request, RestResourceConfigInterface $_rest_resource_config) {
    $resource = $_rest_resource_config->getResourcePlugin();
    $unserialized = $this->deserialize($route_match, $request, $resource);
    $response = $this->delegateToRestResourcePlugin($route_match, $request, $unserialized, $resource);
    return $this->prepareResponse($response, $_rest_resource_config);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.