ENH Add 'Includes' condition option to EmailRecipientCondition (#1275)

This commit is contained in:
Sukhwinder Singh 2024-03-18 04:04:26 +05:30 committed by GitHub
parent 6191b4984d
commit 32d0158954
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 2 deletions

View File

@ -37,11 +37,12 @@ class EmailRecipientCondition extends DataObject
'ValueLessThan' => 'Less than',
'ValueLessThanEqual' => 'Less than or equal',
'ValueGreaterThan' => 'Greater than',
'ValueGreaterThanEqual' => 'Greater than or equal'
'ValueGreaterThanEqual' => 'Greater than or equal',
'Includes' => 'Includes'
];
private static $db = [
'ConditionOption' => 'Enum("IsBlank,IsNotBlank,Equals,NotEquals,ValueLessThan,ValueLessThanEqual,ValueGreaterThan,ValueGreaterThanEqual")',
'ConditionOption' => 'Enum("IsBlank,IsNotBlank,Equals,NotEquals,ValueLessThan,ValueLessThanEqual,ValueGreaterThan,ValueGreaterThanEqual,Includes")',
'ConditionValue' => 'Varchar'
];
@ -96,6 +97,11 @@ class EmailRecipientCondition extends DataObject
$result = !($result);
}
break;
case 'Includes':
$result = is_array($fieldValue)
? in_array($conditionValue, $fieldValue)
: stripos($fieldValue ?? '', $conditionValue) !== false;
break;
default:
throw new LogicException("Unhandled rule {$this->ConditionOption}");
break;