AjaxHelperTrait.php in Drupal 9
File
core/lib/Drupal/Core/Ajax/AjaxHelperTrait.php
View source
<?php
namespace Drupal\Core\Ajax;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
trait AjaxHelperTrait {
protected function isAjax() {
foreach ([
'drupal_ajax',
'drupal_modal',
'drupal_dialog',
] as $wrapper) {
if (strpos($this
->getRequestWrapperFormat(), $wrapper) !== FALSE) {
return TRUE;
}
}
return FALSE;
}
protected function getRequestWrapperFormat() {
return \Drupal::request()
->get(MainContentViewSubscriber::WRAPPER_FORMAT);
}
}
Traits
Name |
Description |
AjaxHelperTrait |
Provides a helper to determine if the current request is via AJAX. |