diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index f684251..3b77798a 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -32,7 +32,7 @@ public function testDialog() { $this->drupalGet('ajax-test/dialog'); // Set up variables for this test. - $dialog_renderable = ajax_test_dialog_contents(); + $dialog_renderable = \Drupal\ajax_test\Controller\AjaxTestController::dialogContents(); $dialog_contents = drupal_render($dialog_renderable); $modal_expected_response = array( 'command' => 'openDialog', diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module index d1faba3..de741fe 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -29,31 +29,6 @@ function ajax_test_error() { } /** - * Returns example content for dialog tests. - */ -function ajax_test_dialog_contents() { - // This is a regular render array; the keys do not have special meaning. - $content = array( - '#title' => 'AJAX Dialog contents', - 'content' => array( - '#markup' => 'Example message', - ), - 'cancel' => array( - '#type' => 'link', - '#title' => 'Cancel', - '#url' => Url::fromRoute(''), - '#attributes' => array( - // This is a special class to which JavaScript assigns dialog closing - // behavior. - 'class' => array('dialog-cancel'), - ), - ), - ); - - return $content; -} - -/** * Menu callback: Close the ajax dialog. * * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::dialogClose() diff --git a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php index c4d40bd..928b84e 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php +++ b/core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php @@ -17,11 +17,31 @@ class AjaxTestController { /** - * Returns example content for dialog testing. + * Example content for dialog testing. + * + * @return array + * Renderable array of AJAX dialog contents. */ - public function dialogContents() { - // Re-use the utility method that returns the example content. - return ajax_test_dialog_contents(); + public static function dialogContents() { + // This is a regular render array; the keys do not have special meaning. + $content = array( + '#title' => 'AJAX Dialog contents', + 'content' => array( + '#markup' => 'Example message', + ), + 'cancel' => array( + '#type' => 'link', + '#title' => 'Cancel', + '#url' => Url::fromRoute(''), + '#attributes' => array( + // This is a special class to which JavaScript assigns dialog closing + // behavior. + 'class' => array('dialog-cancel'), + ), + ), + ); + + return $content; } /** diff --git a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php index b8a7ad4..922ef60 100644 --- a/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php +++ b/core/modules/system/tests/modules/ajax_test/src/Form/AjaxTestDialogForm.php @@ -7,9 +7,8 @@ namespace Drupal\ajax_test\Form; -use Drupal\Core\Form\FormInterface; +use Drupal\ajax_test\Controller\AjaxTestController; use Drupal\Core\Form\FormBase; -use Drupal\Component\Utility\String; use Drupal\Core\Ajax\AjaxResponse; use Drupal\Core\Ajax\OpenModalDialogCommand; use Drupal\Core\Ajax\OpenDialogCommand; @@ -97,7 +96,7 @@ public function nonModal(&$form, FormStateInterface $form_state) { * An ajax response object. */ protected function dialog($is_modal = FALSE) { - $content = ajax_test_dialog_contents(); + $content = AjaxTestController::dialogContents(); $response = new AjaxResponse(); $title = $this->t('AJAX Dialog contents');