Skip to content

Firefly III: a personal finances manager

Overrule "constant" and "enum" actions.

James Cole67b16cc07063
diff --git a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
index f8451e1c6c..7fb6012dcd 100644
--- a/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
+++ b/app/TransactionRules/Expressions/ActionExpressionLanguageProvider.php
@@ -31,7 +31,28 @@ class ActionExpressionLanguageProvider implements ExpressionFunctionProviderInte
{
public function getFunctions(): array
{
+
return [
+
+ new ExpressionFunction('constant', function ($str): string {
+ return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str . '!');
+ }, function ($arguments, $str): string {
+ if (!is_string($str)) {
+ return $str;
+ }
+
+ return strtolower($str . '!');
+ }),
+ new ExpressionFunction('enum', function ($str): string {
+ return sprintf('(is_string(%1$s) ? strtolower(%1$s) : %1$s)', $str . '?');
+ }, function ($arguments, $str): string {
+ if (!is_string($str)) {
+ return $str;
+ }
+
+ return strtolower($str) . '?';
+ }),
+
ExpressionFunction::fromPhp('substr'),
ExpressionFunction::fromPhp('strlen'),
];