3 namespace Drupal\Core\Ajax;
5 use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
8 * Provides a helper to determine if the current request is via AJAX.
12 trait AjaxHelperTrait {
15 * Determines if the current request is via AJAX.
18 * TRUE if the current request is via AJAX, FALSE otherwise.
20 protected function isAjax() {
21 foreach (['drupal_ajax', 'drupal_modal', 'drupal_dialog'] as $wrapper) {
22 if (strpos($this->getRequestWrapperFormat(), $wrapper) !== FALSE) {
30 * Gets the wrapper format of the current request.
35 protected function getRequestWrapperFormat() {
36 return \Drupal::request()->get(MainContentViewSubscriber::WRAPPER_FORMAT);