You are here

public function Parser::parseRequest in Subrequests 8

Parameters

\Symfony\Component\HttpFoundation\Request $request: The master request to parse. We need from it:

File

src/Blueprint/Parser.php, line 46

Class

Parser
TODO: Change this comment. We'll use the serializer instead. Base class for blueprint parsers. There may be slightly different blueprint formats depending on the encoding. For instance, JSON encoded blueprints will reference other properties in…

Namespace

Drupal\subrequests\Blueprint

Code

public function parseRequest(Request $request) {
  $data = '';
  if ($request
    ->getMethod() === Request::METHOD_POST) {
    $data = $request
      ->getContent();
  }
  else {
    if ($request
      ->getMethod() === Request::METHOD_GET) {
      $data = $request->query
        ->get('query', '');
    }
  }
  $tree = $this->serializer
    ->deserialize($data, RequestTree::class, $request
    ->getRequestFormat(), [
    'master_request' => $request,
  ]);
  $request->attributes
    ->set(RequestTree::SUBREQUEST_TREE, $tree);

  // It assumed that all subrequests use the same Mime-Type.
  $this->type = $request
    ->getMimeType($request
    ->getRequestFormat());
}