X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Fdialog_renderer_test%2Fsrc%2FRender%2FMainContent%2FWideModalRenderer.php;fp=web%2Fcore%2Fmodules%2Fsystem%2Ftests%2Fmodules%2Fdialog_renderer_test%2Fsrc%2FRender%2FMainContent%2FWideModalRenderer.php;h=2fd98281803188affd5a423bd633867bb4ecbed0;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php b/web/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php new file mode 100644 index 000000000..2fd982818 --- /dev/null +++ b/web/core/modules/system/tests/modules/dialog_renderer_test/src/Render/MainContent/WideModalRenderer.php @@ -0,0 +1,77 @@ +mode = $mode; + } + + + /** + * {@inheritdoc} + */ + 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 OpenModalDialogCommand and set + // the attachments for this Ajax response. + $main_content['#attached']['library'][] = 'core/drupal.dialog.ajax'; + $response->setAttachments($main_content['#attached']); + + // If the main content doesn't provide a title, use the title resolver. + $title = isset($main_content['#title']) ? $main_content['#title'] : $this->titleResolver->getTitle($request, $route_match->getRouteObject()); + + // Determine the title: use the title provided by the main content if any, + // otherwise get it from the routing information. + $options = $request->request->get('dialogOptions', []); + // Override width option. + switch ($this->mode) { + case 'wide': + $options['width'] = 700; + break; + + case 'extra_wide': + $options['width'] = 1000; + break; + } + + $response->addCommand(new OpenModalDialogCommand($title, $content, $options)); + return $response; + } + +}