You are here

public function ThunderGqlsRenderer::renderResponse in Thunder 6.2.x

Renders the main content render array into a response.

Parameters

array $main_content: The render array representing the main content.

\Symfony\Component\HttpFoundation\Request $request: The request object, for context.

\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match, for context.

Return value

\Symfony\Component\HttpFoundation\Response The Response in the format that this implementation supports.

Overrides MainContentRendererInterface::renderResponse

File

modules/thunder_gqls/src/Render/MainContent/ThunderGqlsRenderer.php, line 97

Class

ThunderGqlsRenderer
Thunder GraphQL Schema content renderer.

Namespace

Drupal\thunder_gqls\Render\MainContent

Code

public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
  $json = [];
  $json['breadcrumb'] = $this
    ->breadcrumb();
  $json['jsonld'] = $this
    ->jsonld();
  $json['language'] = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $response = new CacheableJsonResponse($json, 200);
  $response
    ->addCacheableDependency(CacheableMetadata::createFromRenderArray($main_content));
  return $response;
}