diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc index 965913d..298f0ec 100644 --- a/core/includes/ajax.inc +++ b/core/includes/ajax.inc @@ -1153,17 +1153,3 @@ function ajax_command_add_css($styles) { 'data' => $styles, ); } - -/** - * Helper function that checks whether this is an AJAX request. - * - * @return bool - * Return TRUE if the current request is asking for ajax content, else FALSE. - */ -function ajax_is_ajax_request() { - $container = drupal_container(); - if ($container->has('content_negotiation') && $container->isScopeActive('request')) { - return $container->get('content_negotiation')->getContentType($container->get('request')) == 'ajax'; - } - return FALSE; -} diff --git a/modules/dialog_example/dialog_example.module b/modules/dialog_example/dialog_example.module index 9ad1cfa..ce81e47 100644 --- a/modules/dialog_example/dialog_example.module +++ b/modules/dialog_example/dialog_example.module @@ -113,7 +113,7 @@ function dialog_example_form($form_type, $page_type = 'nojs') { break; } - if (ajax_is_ajax_request()) { + if (Drupal::service('request')->isXmlHttpRequest()) { $response = new AjaxResponse(); $response->addCommand(new openModalDialogCommand('Title', drupal_render($output))); return $response; @@ -173,7 +173,7 @@ function dialog_example_complex_form() { '#weight' => -10, ); - if (ajax_is_ajax_request()) { + if (Drupal::service('request')->isXmlHttpRequest()) { $form['actions']['okayish']['#ajax'] = array( 'callback' => 'dialog_example_complex_okayish', );