trait AjaxHelperTrait
Same name in other branches
- 9 core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait
- 10 core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait
- 11.x core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php \Drupal\Core\Ajax\AjaxHelperTrait
Provides a helper to determine if the current request is via AJAX.
@internal
Hierarchy
- trait \Drupal\Core\Ajax\AjaxHelperTrait
5 files declare their use of AjaxHelperTrait
- AddSectionController.php in core/
modules/ layout_builder/ src/ Controller/ AddSectionController.php - ChooseBlockController.php in core/
modules/ layout_builder/ src/ Controller/ ChooseBlockController.php - ChooseSectionController.php in core/
modules/ layout_builder/ src/ Controller/ ChooseSectionController.php - LayoutBuilder.php in core/
modules/ layout_builder/ src/ Element/ LayoutBuilder.php - WorkspaceListBuilder.php in core/
modules/ workspaces/ src/ WorkspaceListBuilder.php
File
-
core/
lib/ Drupal/ Core/ Ajax/ AjaxHelperTrait.php, line 12
Namespace
Drupal\Core\AjaxView source
trait AjaxHelperTrait {
/**
* Determines if the current request is via AJAX.
*
* @return bool
* TRUE if the current request is via AJAX, FALSE otherwise.
*/
protected function isAjax() {
foreach ([
'drupal_ajax',
'drupal_modal',
'drupal_dialog',
] as $wrapper) {
if (strpos($this->getRequestWrapperFormat(), $wrapper) !== FALSE) {
return TRUE;
}
}
return FALSE;
}
/**
* Gets the wrapper format of the current request.
*
* @string
* The wrapper format.
*/
protected function getRequestWrapperFormat() {
return \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AjaxHelperTrait::getRequestWrapperFormat | protected | function | Gets the wrapper format of the current request. |
AjaxHelperTrait::isAjax | protected | function | Determines if the current request is via AJAX. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.