You are here

public function FrontController::handle in Subrequests 3.x

Same name and namespace in other branches
  1. 8.2 src/Controller/FrontController.php \Drupal\subrequests\Controller\FrontController::handle()
  2. 8 src/Controller/FrontController.php \Drupal\subrequests\Controller\FrontController::handle()

Controller handler.

1 string reference to 'FrontController::handle'
subrequests.routing.yml in ./subrequests.routing.yml
subrequests.routing.yml

File

src/Controller/FrontController.php, line 50

Class

FrontController
Front controller to process Subrequests requests.

Namespace

Drupal\subrequests\Controller

Code

public function handle(Request $request) {
  $data = '';
  if ($request
    ->getMethod() === Request::METHOD_POST) {
    $data = $request
      ->getContent();
  }
  elseif ($request
    ->getMethod() === Request::METHOD_GET) {
    $data = $request->query
      ->get('query', '');
  }
  $tree = $this->blueprintManager
    ->parse($data, $request);
  $responses = $this->subrequestsManager
    ->request($tree);
  $master_request = $tree
    ->getMasterRequest();
  $output_format = $master_request
    ->getRequestFormat();
  if ($output_format === 'html') {

    // Change the default format from html to multipart-related.
    $output_format = 'multipart-related';
  }
  $master_request
    ->getMimeType($output_format);
  return $this->blueprintManager
    ->combineResponses($responses, $output_format);
}