You are here

protected function QueryRouteEnhancer::extractBody in GraphQL 8.3

Same name and namespace in other branches
  1. 8.4 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
Update the defaults based on its own data and the request.

File

src/Routing/QueryRouteEnhancer.php, line 61

Class

QueryRouteEnhancer

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;
}