You are here

protected function QueryRouteEnhancer::extractBody in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 src/Routing/QueryRouteEnhancer.php \Drupal\graphql\Routing\QueryRouteEnhancer::extractBody()

Extracts the body parameters from a request.

Parameters

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

Return value

array The normalized body parameters.

1 call to QueryRouteEnhancer::extractBody()
QueryRouteEnhancer::enhance in src/Routing/QueryRouteEnhancer.php

File

src/Routing/QueryRouteEnhancer.php, line 72

Class

QueryRouteEnhancer
Adds GraphQL operation information to the Symfony route being resolved.

Namespace

Drupal\graphql\Routing

Code

protected function extractBody(Request $request) {
  $values = [];

  // Extract the request content.
  if ($content = json_decode($request
    ->getContent(), TRUE)) {
    $values = array_merge($values, JsonHelper::decodeParams($content));
  }
  if (stripos($request->headers
    ->get('content-type'), 'multipart/form-data') !== FALSE) {
    return $this
      ->extractMultipart($request, $values);
  }
  return $values;
}