You are here

public function Renderer::renderResponse in Colorbox Load 8

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

src/Renderer.php, line 36

Class

Renderer
Render content in a colorbox.

Namespace

Drupal\colorbox_load

Code

public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
  $response = new AjaxResponse();
  $content = $this->renderer
    ->renderPlain($main_content);
  $response
    ->setAttachments($main_content['#attached']);
  $response
    ->addCommand(new OpenCommand($content));
  return $response;
}