You are here

public function SpiController::send in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::send()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::send()

Callback for sending SPI data.

Parameters

\Symfony\Component\HttpFoundation\Request $request: Request.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response Redirect to the destination or return HTTP_BAD_REQUEST|HTTP_OK response.

1 string reference to 'SpiController::send'
acquia_connector.routing.yml in ./acquia_connector.routing.yml
acquia_connector.routing.yml

File

src/Controller/SpiController.php, line 1036

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

public function send(Request $request) {

  // Mark this page as being uncacheable.
  \Drupal::service('page_cache_kill_switch')
    ->trigger();
  $method = ACQUIA_CONNECTOR_ACQUIA_SPI_METHOD_CALLBACK;

  // Insight's set variable feature will pass method insight.
  if ($request->query
    ->has('method') && $request->query
    ->get('method') === ACQUIA_CONNECTOR_ACQUIA_SPI_METHOD_INSIGHT) {
    $method = ACQUIA_CONNECTOR_ACQUIA_SPI_METHOD_INSIGHT;
  }
  $response = $this
    ->sendFullSpi($method);
  if ($request
    ->get('destination')) {
    $this
      ->spiProcessMessages($response);
    $route_match = RouteMatch::createFromRequest($request);
    return $this
      ->redirect($route_match
      ->getRouteName(), $route_match
      ->getRawParameters()
      ->all());
  }
  $headers = [
    'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT',
    'Content-Type' => 'text/plain',
    'Cache-Control' => 'no-cache',
    'Pragma' => 'no-cache',
  ];
  if (empty($response['body'])) {
    return new Response('', Response::HTTP_BAD_REQUEST, $headers);
  }
  return new Response('', Response::HTTP_OK, $headers);
}