Overrule "constant" and "enum" actions.

This commit is contained in:
James Cole 2024-03-10 06:46:38 +01:00
parent 5746ac3247
commit 67b16cc070
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -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'),
];