Add feature flag for expression engine and disable it by default.

This commit is contained in:
James Cole
2024-03-10 06:46:24 +01:00
parent 8a2c520b11
commit 5746ac3247
4 changed files with 87 additions and 88 deletions

View File

@@ -66,18 +66,21 @@ class RuleAction extends Model
use ReturnsIntegerIdTrait;
protected $casts
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'active' => 'boolean',
'order' => 'int',
'stop_processing' => 'boolean',
];
= [
'created_at' => 'datetime',
'updated_at' => 'datetime',
'active' => 'boolean',
'order' => 'int',
'stop_processing' => 'boolean',
];
protected $fillable = ['rule_id', 'action_type', 'action_value', 'order', 'active', 'stop_processing'];
public function getValue(array $journal): string
{
if (false === config('firefly.feature_flags.expression_engine')) {
return (string)$this->action_value;
}
$expr = new ActionExpression($this->action_value);
return $expr->evaluate($journal);
@@ -91,14 +94,14 @@ class RuleAction extends Model
protected function order(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn($value) => (int)$value,
);
}
protected function ruleId(): Attribute
{
return Attribute::make(
get: static fn ($value) => (int)$value,
get: static fn($value) => (int)$value,
);
}
}