diff --git a/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php index f98fb71..07dce6e 100644 --- a/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php @@ -51,9 +51,10 @@ class MainContentViewSubscriber implements EventSubscriberInterface { /** * URL query attribute to indicate the wrapper used to render a request. * - * This controls wrapping the HTML content for example in a modal dialog. + * The wrapper format determines how the HTML is wrapped, for example in a + * modal dialog. */ - const WRAPPER_ENVELOPE = '_wrapper_format'; + const WRAPPER_FORMAT = '_wrapper_format'; /** * Constructs a new MainContentViewSubscriber object. @@ -82,8 +83,8 @@ public function onViewRenderArray(GetResponseForControllerResultEvent $event) { $result = $event->getControllerResult(); // Render the controller result into a response if it's a render array. - if (is_array($result) && ($request->query->has(static::WRAPPER_ENVELOPE) || $request->getRequestFormat() == 'html')) { - $wrapper = $request->query->get(static::WRAPPER_ENVELOPE, 'html'); + if (is_array($result) && ($request->query->has(static::WRAPPER_FORMAT) || $request->getRequestFormat() == 'html')) { + $wrapper = $request->query->get(static::WRAPPER_FORMAT, 'html'); // Fall back to HTML if the requested wrapper envelope is not available. $wrapper = isset($this->mainContentRenderers[$wrapper]) ? $wrapper : 'html'; diff --git a/core/misc/ajax.js b/core/misc/ajax.js index c1dd726..d80c2c5 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -271,7 +271,7 @@ else { ajax.options.url += '&'; } - ajax.options.url += Drupal.ajax.WRAPPER_ENVELOPE + '=drupal_' + (element_settings.dialogType || 'ajax'); + ajax.options.url += Drupal.ajax.WRAPPER_FORMAT + '=drupal_' + (element_settings.dialogType || 'ajax'); // Bind the ajaxSubmit function to the element event. $(ajax.element).on(element_settings.event, function (event) { @@ -298,9 +298,10 @@ /** * URL query attribute to indicate the wrapper used to render a request. * - * This controls wrapping the HTML content for example in a modal dialog. + * The wrapper format determines how the HTML is wrapped, for example in a + * modal dialog. */ - Drupal.ajax.WRAPPER_ENVELOPE = '_wrapper_format'; + Drupal.ajax.WRAPPER_FORMAT = '_wrapper_format'; /** * Handle a key press. diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index e276832..99cb227 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -1423,8 +1423,8 @@ protected function drupalGetJSON($path, array $options = array(), array $headers * Requests a Drupal path in drupal_ajax format and JSON-decodes the response. */ protected function drupalGetAjax($path, array $options = array(), array $headers = array()) { - if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE])) { - $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE] = 'drupal_ajax'; + if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT])) { + $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax'; } return Json::decode($this->drupalGet($path, $options, $headers)); } @@ -1659,16 +1659,16 @@ protected function drupalPostAjaxForm($path, $edit, $triggering_element, $ajax_p // Avoid sending the wrapper query argument to drupalGet so we can fetch // the form and populate the internal WebTest values. $get_options = $options; - unset($get_options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE]); + unset($get_options['query'][MainContentViewSubscriber::WRAPPER_FORMAT]); $this->drupalGet($path, $get_options); } $content = $this->content; $drupal_settings = $this->drupalSettings; // Provide a default value for the wrapper envelope. - $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE] = - isset($options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE]) ? - $options['query'][MainContentViewSubscriber::WRAPPER_ENVELOPE] : + $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = + isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT]) ? + $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] : 'drupal_ajax'; // Get the Ajax settings bound to the triggering element. diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index 3783443..e290977 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -94,7 +94,7 @@ public function testDialog() { $this->assertRaw($dialog_contents, 'Non-JS modal dialog page present.'); // Emulate going to the JS version of the page and check the JSON response. - $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_ENVELOPE => 'drupal_modal'))); + $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); $this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.'); // Check that requesting a "normal" dialog without JS goes to a page. @@ -107,7 +107,7 @@ public function testDialog() { $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array( // We have to mock a form element to make drupalPost submit from a link. 'textfield' => 'test', - ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_ENVELOPE => 'drupal_dialog')), array(), NULL, array( + ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array( 'submit' => array( 'dialogOptions[target]' => 'ajax-test-dialog-wrapper-1', ) @@ -120,7 +120,7 @@ public function testDialog() { $ajax_result = $this->drupalPostAjaxForm('ajax-test/dialog', array( // We have to mock a form element to make drupalPost submit from a link. 'textfield' => 'test', - ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_ENVELOPE => 'drupal_dialog')), array(), NULL, array( + ), array(), 'ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_dialog')), array(), NULL, array( // Don't send a target. 'submit' => array() )); @@ -160,7 +160,7 @@ public function testDialog() { $this->assertTrue(!empty($form), 'Non-JS form page present.'); // Emulate going to the JS version of the form and check the JSON response. - $ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', array('query' => array(MainContentViewSubscriber::WRAPPER_ENVELOPE => 'drupal_modal'))); + $ajax_result = $this->drupalGetAjax('ajax-test/dialog-form', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); $expected_ajax_settings = [ 'edit-preview' => [ 'callback' => '::preview', @@ -189,7 +189,7 @@ public function testDialog() { $this->assertTrue(!empty($form), 'Non-JS entity form page present.'); // Emulate going to the JS version of the form and check the JSON response. - $ajax_result = $this->drupalGetAjax('admin/structure/contact/add', array('query' => array(MainContentViewSubscriber::WRAPPER_ENVELOPE => 'drupal_modal'))); + $ajax_result = $this->drupalGetAjax('admin/structure/contact/add', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal'))); $this->setRawContent($ajax_result[3]['data']); // Remove the data, the form build id and token will never match. unset($ajax_result[3]['data']);