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 0000000000000000000000000000000000000000..6fce2f2b5ab46b7aae888a887da165b88c475891 --- /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); + } + +}