function DialogRenderer::renderResponse

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::renderResponse()
  2. 8.9.x core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::renderResponse()
  3. 11.x core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php \Drupal\Core\Render\MainContent\DialogRenderer::renderResponse()

Overrides MainContentRendererInterface::renderResponse

2 methods override DialogRenderer::renderResponse()
ModalRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/ModalRenderer.php
Renders the main content render array into a response.
OffCanvasRenderer::renderResponse in core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php
Renders the main content render array into a response.

File

core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php, line 48

Class

DialogRenderer
Default main content renderer for dialog requests.

Namespace

Drupal\Core\Render\MainContent

Code

public function renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match) {
    $response = new AjaxResponse();
    // First render the main content, because it might provide a title.
    $content = $this->renderer
        ->renderRoot($main_content);
    // Attach the library necessary for using the OpenDialogCommand and set the
    // attachments for this Ajax response.
    $main_content['#attached']['library'][] = 'core/drupal.dialog.ajax';
    $response->setAttachments($main_content['#attached']);
    // Determine the title.
    $title = $this->getTitleAsStringable($main_content, $request, $route_match);
    // Determine the dialog options and the target for the OpenDialogCommand.
    $options = $this->getDialogOptions($request);
    $target = $this->determineTargetSelector($options, $route_match);
    $response->addCommand(new OpenDialogCommand($target, $title, $content, $options));
    return $response;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.