mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-17 09:51:40 +00:00
Merge branch 'feature/test-triggers' of github.com:roberthorlings/firefly-iii into feature/test-triggers
This commit is contained in:
@@ -15,9 +15,9 @@ use FireflyIII\Models\RuleAction;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Rules\Actions\ActionInterface;
|
||||
use FireflyIII\Rules\Actions\ActionFactory;
|
||||
use FireflyIII\Rules\Triggers\TriggerInterface;
|
||||
use FireflyIII\Rules\Triggers\TriggerFactory;
|
||||
use FireflyIII\Support\Domain;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
@@ -31,6 +31,10 @@ class Processor
|
||||
protected $journal;
|
||||
/** @var Rule */
|
||||
protected $rule;
|
||||
/** @var array */
|
||||
private $actionTypes = [];
|
||||
/** @var array */
|
||||
private $triggerTypes = [];
|
||||
|
||||
/**
|
||||
* Processor constructor.
|
||||
@@ -42,6 +46,8 @@ class Processor
|
||||
{
|
||||
$this->rule = $rule;
|
||||
$this->journal = $journal;
|
||||
$this->triggerTypes = Domain::getRuleTriggers();
|
||||
$this->actionTypes = Domain::getRuleActions();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,6 +119,12 @@ class Processor
|
||||
* @var RuleAction $action
|
||||
*/
|
||||
foreach ($this->rule->ruleActions()->orderBy('order', 'ASC')->get() as $action) {
|
||||
$type = $action->action_type;
|
||||
$class = $this->actionTypes[$type];
|
||||
Log::debug('Action #' . $action->id . ' for rule #' . $action->rule_id . ' (' . $type . ')');
|
||||
if (!class_exists($class)) {
|
||||
abort(500, 'Could not instantiate class for rule action type "' . $type . '" (' . $class . ').');
|
||||
}
|
||||
/** @var ActionInterface $actionClass */
|
||||
$actionClass = ActionFactory::getAction($action, $this->journal);
|
||||
$actionClass->act();
|
||||
@@ -126,6 +138,8 @@ class Processor
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check whether the current transaction would be triggered
|
||||
* by the given list of triggers
|
||||
* @return bool
|
||||
*/
|
||||
protected function triggeredBy($triggers) {
|
||||
|
Reference in New Issue
Block a user