Skip to content
Snippets Groups Projects
Commit fa9e1854 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #1987612 by valthebald, Mile23, aspilicious, Pinolo, InternetDevels:...

Issue #1987612 by valthebald, Mile23, aspilicious, Pinolo, InternetDevels: Convert ajax_test_dialog_contents() to a new style controller
parent d6c4991d
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
......@@ -28,31 +28,6 @@ function ajax_test_error() {
return $response;
}
/**
* 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('<front>'),
'#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.
*
......
......@@ -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('<front>'),
'#attributes' => array(
// This is a special class to which JavaScript assigns dialog closing
// behavior.
'class' => array('dialog-cancel'),
),
),
);
return $content;
}
/**
......
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment