You are here

protected function DumpAssets::getResponse in Acquia Content Hub 8.2

Make a signed response specifically for the Handle webhook event.

Parameters

\Drupal\acquia_contenthub\Event\HandleWebhookEvent $event: Handle webhook event.

string $body: Response body.

Return value

\Psr\Http\Message\ResponseInterface Signed response.

1 call to DumpAssets::getResponse()
DumpAssets::onHandleWebhook in modules/acquia_contenthub_subscriber/src/EventSubscriber/HandleWebhook/DumpAssets.php
Handles webhook events.

File

modules/acquia_contenthub_subscriber/src/EventSubscriber/HandleWebhook/DumpAssets.php, line 130

Class

DumpAssets
Class DumpAssets.

Namespace

Drupal\acquia_contenthub_subscriber\EventSubscriber\HandleWebhook

Code

protected function getResponse(HandleWebhookEvent $event, string $body) {
  $response = new Response(SymfonyResponse::HTTP_OK, [], $body);
  if (class_exists(DiactorosFactory::class)) {
    $httpMessageFactory = new DiactorosFactory();
  }
  else {
    $httpMessageFactory = new PsrHttpFactory(new ServerRequestFactory(), new StreamFactory(), new UploadedFileFactory(), new ResponseFactory());
  }
  $psr7Request = $httpMessageFactory
    ->createRequest($event
    ->getRequest());
  $signer = new ResponseSigner($event
    ->getKey(), $psr7Request);
  $signedResponse = $signer
    ->signResponse($response);
  return $signedResponse;
}