Expand search.

This commit is contained in:
James Cole
2020-08-22 12:24:01 +02:00
parent d69934ca8f
commit ffca935ced
21 changed files with 3514 additions and 322 deletions

View File

@@ -41,6 +41,7 @@ use Log;
* Set the user, then apply an array to setRulesToApply(array) or call addRuleIdToApply(int) or addRuleToApply(Rule).
* Then call process() to make the magic happen.
*
* @deprecated
*/
class RuleEngine
{
@@ -50,18 +51,12 @@ class RuleEngine
public const TRIGGER_UPDATE = 2;
/** @var int */
public const TRIGGER_BOTH = 3;
/** @var bool */
private $allRules;
/** @var RuleGroupRepository */
private $ruleGroupRepository;
/** @var Collection */
private $ruleGroups;
/** @var array */
private $rulesToApply;
/** @var int */
private $triggerMode;
/** @var User */
private $user;
private bool $allRules;
private RuleGroupRepository $ruleGroupRepository;
private Collection $ruleGroups;
private array $rulesToApply;
private int $triggerMode;
private User $user;
/**
* RuleEngine constructor.
@@ -230,7 +225,7 @@ class RuleEngine
$validTrigger = ('store-journal' === $trigger->trigger_value && self::TRIGGER_STORE === $this->triggerMode)
|| ('update-journal' === $trigger->trigger_value && self::TRIGGER_UPDATE === $this->triggerMode)
|| $this->triggerMode === self::TRIGGER_BOTH;
|| $this->triggerMode === self::TRIGGER_BOTH;
return $validTrigger && ($this->allRules || in_array($rule->id, $this->rulesToApply, true)) && true === $rule->active;
}

View File

@@ -0,0 +1,35 @@
<?php
/*
* RuleEngineInterface.php
* Copyright (c) 2020 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace FireflyIII\TransactionRules\Engine;
use Illuminate\Support\Collection;
/**
* Interface RuleEngineInterface
*/
interface RuleEngineInterface
{
public function setRules(Collection $rules): void;
public function setRuleGroups(Collection $ruleGroups): void;
}