From a746643b510fc3401393e9ccba444741b07d895d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCrgen=20Haas?=
 <21467-jurgenhaas@users.noreply.drupalcode.org>
Date: Fri, 18 Apr 2025 10:00:52 +0000
Subject: [PATCH] Issue #3519888 by jurgenhaas: ECA Misc: Add condition to see
 if the current request is ajax

---
 .../src/Plugin/ECA/Condition/IsAjax.php       | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 modules/miscellaneous/src/Plugin/ECA/Condition/IsAjax.php

diff --git a/modules/miscellaneous/src/Plugin/ECA/Condition/IsAjax.php b/modules/miscellaneous/src/Plugin/ECA/Condition/IsAjax.php
new file mode 100644
index 00000000..6fce2f2b
--- /dev/null
+++ b/modules/miscellaneous/src/Plugin/ECA/Condition/IsAjax.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Drupal\eca_misc\Plugin\ECA\Condition;
+
+use Drupal\Core\Ajax\AjaxHelperTrait;
+use Drupal\eca\Plugin\ECA\Condition\ConditionBase;
+
+/**
+ * Condition plugin to determine if the current request is an AJAX request.
+ *
+ * @EcaCondition(
+ *   id = "eca_is_ajax",
+ *   label = "Is Ajax",
+ *   description = @Translation("Determines if the current request is an AJAX request."),
+ *   eca_version_introduced = "2.1.8"
+ * )
+ */
+class IsAjax extends ConditionBase {
+
+  use AjaxHelperTrait;
+
+  /**
+   * {@inheritdoc}
+   */
+  public function evaluate(): bool {
+    $result = $this->isAjax();
+    return $this->negationCheck($result);
+  }
+
+}
-- 
GitLab