You are here

public static function Utility::isAjaxRequest in AJAX Comments 8

Check if a request was made through ajax.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The current request object.

array $input: (optional) The form input returned from $form_state->getUserInput().

Return value

bool Whether or not the request was made using ajax.

9 calls to Utility::isAjaxRequest()
AjaxCommentsController::edit in src/Controller/AjaxCommentsController.php
Returns the comment edit form.
AjaxCommentsController::reply in src/Controller/AjaxCommentsController.php
Builds ajax response to display a form to reply to another comment.
AjaxCommentsDeleteForm::buildForm in src/Form/AjaxCommentsDeleteForm.php
Form constructor.
AjaxCommentsDeleteForm::submitForm in src/Form/AjaxCommentsDeleteForm.php
This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state…
AjaxCommentsForm::buildForm in src/Form/AjaxCommentsForm.php
Form constructor.

... See full list

File

src/Utility.php, line 184

Class

Utility
Provides various helper methods for Ajax Comments.

Namespace

Drupal\ajax_comments

Code

public static function isAjaxRequest(Request $request, $input = []) {
  $has_ajax_parameter = $request->request
    ->has(AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER);
  $has_ajax_input_parameter = !empty($input[AjaxResponseSubscriber::AJAX_REQUEST_PARAMETER]);
  $has_ajax_format = $request->query
    ->get(MainContentViewSubscriber::WRAPPER_FORMAT) == 'drupal_ajax';
  return $has_ajax_parameter || $has_ajax_input_parameter || $has_ajax_format;
}