mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 08:35:00 +00:00
Refactor rule creation.
This commit is contained in:
@@ -292,7 +292,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$rule->order = ($order + 1);
|
||||
$rule->active = true;
|
||||
$rule->strict = $data['strict'] ?? false;
|
||||
$rule->stop_processing = 1 === (int)$data['stop-processing'];
|
||||
$rule->stop_processing = 1 === (int)$data['stop_processing'];
|
||||
$rule->title = $data['title'];
|
||||
$rule->description = \strlen($data['description']) > 0 ? $data['description'] : null;
|
||||
|
||||
@@ -319,7 +319,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$ruleAction->rule()->associate($rule);
|
||||
$ruleAction->order = $values['order'];
|
||||
$ruleAction->active = true;
|
||||
$ruleAction->stop_processing = $values['stopProcessing'];
|
||||
$ruleAction->stop_processing = $values['stop_processing'];
|
||||
$ruleAction->action_type = $values['action'];
|
||||
$ruleAction->action_value = $values['value'] ?? '';
|
||||
$ruleAction->save();
|
||||
@@ -339,7 +339,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$ruleTrigger->rule()->associate($rule);
|
||||
$ruleTrigger->order = $values['order'];
|
||||
$ruleTrigger->active = true;
|
||||
$ruleTrigger->stop_processing = $values['stopProcessing'];
|
||||
$ruleTrigger->stop_processing = $values['stop_processing'];
|
||||
$ruleTrigger->trigger_type = $values['action'];
|
||||
$ruleTrigger->trigger_value = $values['value'] ?? '';
|
||||
$ruleTrigger->save();
|
||||
@@ -358,7 +358,7 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
// update rule:
|
||||
$rule->rule_group_id = $data['rule_group_id'];
|
||||
$rule->active = $data['active'];
|
||||
$rule->stop_processing = $data['stop-processing'];
|
||||
$rule->stop_processing = $data['stop_processing'];
|
||||
$rule->title = $data['title'];
|
||||
$rule->strict = $data['strict'] ?? false;
|
||||
$rule->description = $data['description'];
|
||||
@@ -388,15 +388,15 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
private function storeActions(Rule $rule, array $data): bool
|
||||
{
|
||||
$order = 1;
|
||||
foreach ($data['rule-actions'] as $action) {
|
||||
foreach ($data['rule_actions'] as $action) {
|
||||
$value = $action['value'] ?? '';
|
||||
$stopProcessing = $action['stop-processing'] ?? false;
|
||||
$stopProcessing = $action['stop_processing'] ?? false;
|
||||
|
||||
$actionValues = [
|
||||
'action' => $action['name'],
|
||||
'value' => $value,
|
||||
'stopProcessing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
'action' => $action['name'],
|
||||
'value' => $value,
|
||||
'stop_processing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
];
|
||||
|
||||
$this->storeAction($rule, $actionValues);
|
||||
@@ -417,22 +417,22 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
$stopProcessing = false;
|
||||
|
||||
$triggerValues = [
|
||||
'action' => 'user_action',
|
||||
'value' => $data['trigger'],
|
||||
'stopProcessing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
'action' => 'user_action',
|
||||
'value' => $data['trigger'],
|
||||
'stop_processing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
];
|
||||
|
||||
$this->storeTrigger($rule, $triggerValues);
|
||||
foreach ($data['rule-triggers'] as $trigger) {
|
||||
foreach ($data['rule_triggers'] as $trigger) {
|
||||
$value = $trigger['value'] ?? '';
|
||||
$stopProcessing = $trigger['stop-processing'] ?? false;
|
||||
$stopProcessing = $trigger['stop_processing'] ?? false;
|
||||
|
||||
$triggerValues = [
|
||||
'action' => $trigger['name'],
|
||||
'value' => $value,
|
||||
'stopProcessing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
'action' => $trigger['name'],
|
||||
'value' => $value,
|
||||
'stop_processing' => $stopProcessing,
|
||||
'order' => $order,
|
||||
];
|
||||
|
||||
$this->storeTrigger($rule, $triggerValues);
|
||||
|
Reference in New Issue
Block a user