function AjaxHelperTrait::isAjax

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait::isAjax()
  2. 10 core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait::isAjax()
  3. 8.9.x core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait::isAjax()

Determines if the current request is via AJAX.

Return value

bool TRUE if the current request is via AJAX, FALSE otherwise.

3 calls to AjaxHelperTrait::isAjax()
ChooseSectionController::build in core/modules/layout_builder/src/Controller/ChooseSectionController.php
Choose a layout plugin to add as a section.
ConfigureSectionForm::buildForm in core/modules/layout_builder/src/Form/ConfigureSectionForm.php
Form constructor.
LayoutBuilder::layout in core/modules/layout_builder/src/Element/LayoutBuilder.php
Renders the Layout UI.

File

core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php, line 20

Class

AjaxHelperTrait
Provides a helper to determine if the current request is via AJAX.

Namespace

Drupal\Core\Ajax

Code

protected function isAjax() {
  $wrapper_format = $this->getRequestWrapperFormat() ?? '';
  return str_contains($wrapper_format, 'drupal_ajax') || str_contains($wrapper_format, 'drupal_modal') || str_contains($wrapper_format, 'drupal_dialog');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.