function OffCanvasRenderer::renderResponse

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

Overrides DialogRenderer::renderResponse

File

core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php, line 52

Class

OffCanvasRenderer
Default main content renderer for off-canvas 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 OpenOffCanvasDialogCommand and
    // set the attachments for this Ajax response.
    $main_content['#attached']['library'][] = 'core/drupal.dialog.off_canvas';
    $response->setAttachments($main_content['#attached']);
    // Determine the title.
    $title = $this->getTitleAsStringable($main_content, $request, $route_match);
    // Determine the title: use the title provided by the main content if any,
    // otherwise get it from the routing information.
    $options = $request->request
        ->all('dialogOptions');
    $response->addCommand(new OpenOffCanvasDialogCommand($title, $content, $options, NULL, $this->position));
    return $response;
}

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