public DialogRenderer::renderResponse(array $main_content, Request $request, RouteMatchInterface $route_match)
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
- core/lib/Drupal/Core/Render/MainContent/DialogRenderer.php, line 37
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 = drupal_render_root($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: use the title provided by the main content if any, // otherwise get it from the routing information. $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); // Determine the dialog options and the target for the OpenDialogCommand. $options = $request->request->get('dialogOptions', array()); $target = $this->determineTargetSelector($options, $route_match); $response->addCommand(new OpenDialogCommand($target, $title, $content, $options)); return $response; }
Please login to continue.