Expand rules and bills.

This commit is contained in:
James Cole
2018-04-14 20:31:31 +02:00
parent 926c03986c
commit 15a22f0bfc
13 changed files with 90 additions and 36 deletions

View File

@@ -49,6 +49,8 @@ final class Processor
public $triggers;
/** @var int Found triggers */
private $foundTriggers = 0;
/** @var bool */
private $strict = true;
/**
* Processor constructor.
@@ -72,9 +74,11 @@ final class Processor
public static function make(Rule $rule, $includeActions = true)
{
Log::debug(sprintf('Making new rule from Rule %d', $rule->id));
$self = new self;
$self->rule = $rule;
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
Log::debug(sprintf('Rule is strict: %s', var_export($rule->strict, true)));
$self = new self;
$self->rule = $rule;
$self->strict = $rule->strict;
$triggerSet = $rule->ruleTriggers()->orderBy('order', 'ASC')->get();
/** @var RuleTrigger $trigger */
foreach ($triggerSet as $trigger) {
Log::debug(sprintf('Push trigger %d', $trigger->id));
@@ -274,6 +278,12 @@ final class Processor
if ($trigger->triggered($this->journal)) {
Log::debug('Is a match!');
++$hitTriggers;
// is non-strict? then return true!
if (!$this->strict) {
Log::debug('Rule is set as non-strict, return true!');
return true;
}
}
if ($trigger->stopProcessing) {
Log::debug('Stop processing this trigger and break.');