mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-23 22:35:03 +00:00
Changed trigger constructor. No longer needs model AND journal, now only model. Wait for it...
This commit is contained in:
@@ -112,9 +112,9 @@ class Processor
|
|||||||
foreach ($this->triggers as $trigger) {
|
foreach ($this->triggers as $trigger) {
|
||||||
$foundTriggers++;
|
$foundTriggers++;
|
||||||
|
|
||||||
/** @var TriggerInterface $triggerClass */
|
/** @var TriggerInterface $triggerObject */
|
||||||
$triggerClass = TriggerFactory::getTrigger($trigger, $this->journal);
|
$triggerObject = TriggerFactory::getTrigger($trigger);
|
||||||
if ($triggerClass->triggered()) {
|
if ($triggerObject->triggered()) {
|
||||||
$hitTriggers++;
|
$hitTriggers++;
|
||||||
}
|
}
|
||||||
if ($trigger->stop_processing) {
|
if ($trigger->stop_processing) {
|
||||||
|
@@ -22,8 +22,7 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class AmountExactly implements TriggerInterface
|
class AmountExactly implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -31,12 +30,11 @@ class AmountExactly implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,11 +63,13 @@ class AmountExactly implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$amount = $this->journal->amount_positive;
|
$amount = $journal->amount_positive;
|
||||||
$compare = $this->trigger->trigger_value;
|
$compare = $this->trigger->trigger_value;
|
||||||
$result = bccomp($amount, $compare, 4);
|
$result = bccomp($amount, $compare, 4);
|
||||||
if ($result === 0) {
|
if ($result === 0) {
|
||||||
|
@@ -22,8 +22,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class AmountLess implements TriggerInterface
|
class AmountLess implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -31,12 +31,11 @@ class AmountLess implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,11 +64,13 @@ class AmountLess implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$amount = $this->journal->amount_positive;
|
$amount = $journal->amount_positive;
|
||||||
$compare = $this->trigger->trigger_value;
|
$compare = $this->trigger->trigger_value;
|
||||||
$result = bccomp($amount, $compare, 4);
|
$result = bccomp($amount, $compare, 4);
|
||||||
if ($result === -1) {
|
if ($result === -1) {
|
||||||
|
@@ -22,8 +22,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class AmountMore implements TriggerInterface
|
class AmountMore implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -31,12 +31,11 @@ class AmountMore implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,11 +64,13 @@ class AmountMore implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$amount = $this->journal->amount_positive;
|
$amount = $journal->amount_positive;
|
||||||
$compare = $this->trigger->trigger_value;
|
$compare = $this->trigger->trigger_value;
|
||||||
$result = bccomp($amount, $compare, 4);
|
$result = bccomp($amount, $compare, 4);
|
||||||
if ($result === 1) {
|
if ($result === 1) {
|
||||||
|
@@ -22,8 +22,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class DescriptionContains implements TriggerInterface
|
class DescriptionContains implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -31,12 +31,11 @@ class DescriptionContains implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,12 +64,14 @@ class DescriptionContains implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
$source = strtolower($this->journal->description);
|
$source = strtolower($journal->description);
|
||||||
|
|
||||||
$strpos = strpos($source, $search);
|
$strpos = strpos($source, $search);
|
||||||
if (!($strpos === false)) {
|
if (!($strpos === false)) {
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class DescriptionEnds implements TriggerInterface
|
class DescriptionEnds implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,12 +30,11 @@ class DescriptionEnds implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,11 +63,13 @@ class DescriptionEnds implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$description = strtolower($this->journal->description);
|
$description = strtolower($journal->description);
|
||||||
$descriptionLength = strlen($description);
|
$descriptionLength = strlen($description);
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
$searchLength = strlen($search);
|
$searchLength = strlen($search);
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class DescriptionIs implements TriggerInterface
|
class DescriptionIs implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,30 +30,10 @@ class DescriptionIs implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$description = strtolower($this->journal->description);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
|
|
||||||
if ($description == $search) {
|
|
||||||
Log::debug('"' . $description . '" equals "' . $search . '" exactly. Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $description . '" does not equal "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,4 +61,25 @@ class DescriptionIs implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$description = strtolower($journal->description);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
|
if ($description == $search) {
|
||||||
|
Log::debug('"' . $description . '" equals "' . $search . '" exactly. Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $description . '" does not equal "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class DescriptionStarts implements TriggerInterface
|
class DescriptionStarts implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,32 +30,10 @@ class DescriptionStarts implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$description = strtolower($this->journal->description);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
|
|
||||||
$part = substr($description, 0, strlen($search));
|
|
||||||
|
|
||||||
if ($part == $search) {
|
|
||||||
Log::debug('"' . $description . '" starts with "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $description . '" does not start with "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +61,27 @@ class DescriptionStarts implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$description = strtolower($journal->description);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
|
$part = substr($description, 0, strlen($search));
|
||||||
|
|
||||||
|
if ($part == $search) {
|
||||||
|
Log::debug('"' . $description . '" starts with "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $description . '" does not start with "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class FromAccountContains implements TriggerInterface
|
class FromAccountContains implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,34 +30,10 @@ class FromAccountContains implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$fromAccountName = strtolower($this->journal->source_account->name);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
$strpos = strpos($fromAccountName, $search);
|
|
||||||
|
|
||||||
if (!($strpos === false)) {
|
|
||||||
// found something
|
|
||||||
Log::debug('"' . $fromAccountName . '" contains the text "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// found nothing.
|
|
||||||
Log::debug('"' . $fromAccountName . '" does not contain the text "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,4 +61,29 @@ class FromAccountContains implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$fromAccountName = strtolower($journal->source_account->name);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
$strpos = strpos($fromAccountName, $search);
|
||||||
|
|
||||||
|
if (!($strpos === false)) {
|
||||||
|
// found something
|
||||||
|
Log::debug('"' . $fromAccountName . '" contains the text "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// found nothing.
|
||||||
|
Log::debug('"' . $fromAccountName . '" does not contain the text "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class FromAccountEnds implements TriggerInterface
|
class FromAccountEnds implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,44 +30,10 @@ class FromAccountEnds implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$name = strtolower($this->journal->source_account->name);
|
|
||||||
$nameLength = strlen($name);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
$searchLength = strlen($search);
|
|
||||||
|
|
||||||
// if the string to search for is longer than the account name,
|
|
||||||
// shorten the search string.
|
|
||||||
if ($searchLength > $nameLength) {
|
|
||||||
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $name . '" (' . $nameLength . '). ');
|
|
||||||
$search = substr($search, ($nameLength * -1));
|
|
||||||
$searchLength = strlen($search);
|
|
||||||
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$part = substr($name, $searchLength * -1);
|
|
||||||
|
|
||||||
if ($part == $search) {
|
|
||||||
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,4 +61,39 @@ class FromAccountEnds implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$name = strtolower($journal->source_account->name);
|
||||||
|
$nameLength = strlen($name);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
$searchLength = strlen($search);
|
||||||
|
|
||||||
|
// if the string to search for is longer than the account name,
|
||||||
|
// shorten the search string.
|
||||||
|
if ($searchLength > $nameLength) {
|
||||||
|
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $name . '" (' . $nameLength . '). ');
|
||||||
|
$search = substr($search, ($nameLength * -1));
|
||||||
|
$searchLength = strlen($search);
|
||||||
|
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$part = substr($name, $searchLength * -1);
|
||||||
|
|
||||||
|
if ($part == $search) {
|
||||||
|
Log::debug('"' . $name . '" ends with "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $name . '" does not end with "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class FromAccountIs implements TriggerInterface
|
class FromAccountIs implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,12 +30,11 @@ class FromAccountIs implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,11 +63,13 @@ class FromAccountIs implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$fromAccountName = strtolower($this->journal->source_account->name);
|
$fromAccountName = strtolower($journal->source_account->name);
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
if ($fromAccountName == $search) {
|
if ($fromAccountName == $search) {
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class FromAccountStarts implements TriggerInterface
|
class FromAccountStarts implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,12 +30,11 @@ class FromAccountStarts implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,11 +63,13 @@ class FromAccountStarts implements TriggerInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
$fromAccountName = strtolower($this->journal->source_account->name);
|
$fromAccountName = strtolower($journal->source_account->name);
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
$part = substr($fromAccountName, 0, strlen($search));
|
$part = substr($fromAccountName, 0, strlen($search));
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class ToAccountContains implements TriggerInterface
|
class ToAccountContains implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,38 +30,13 @@ class ToAccountContains implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$toAccountName = strtolower($this->journal->destination_account->name);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
$strpos = strpos($toAccountName, $search);
|
|
||||||
|
|
||||||
if (!($strpos === false)) {
|
|
||||||
// found something
|
|
||||||
Log::debug('"' . $toAccountName . '" contains the text "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// found nothing.
|
|
||||||
Log::debug('"' . $toAccountName . '" does not contain the text "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trigger is said to "match anything", or match any given transaction,
|
* A trigger is said to "match anything", or match any given transaction,
|
||||||
* when the trigger value is very vague or has no restrictions. Easy examples
|
* when the trigger value is very vague or has no restrictions. Easy examples
|
||||||
@@ -86,4 +61,29 @@ class ToAccountContains implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$toAccountName = strtolower($journal->destination_account->name);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
$strpos = strpos($toAccountName, $search);
|
||||||
|
|
||||||
|
if (!($strpos === false)) {
|
||||||
|
// found something
|
||||||
|
Log::debug('"' . $toAccountName . '" contains the text "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// found nothing.
|
||||||
|
Log::debug('"' . $toAccountName . '" does not contain the text "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class ToAccountEnds implements TriggerInterface
|
class ToAccountEnds implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,44 +30,10 @@ class ToAccountEnds implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$toAccountName = strtolower($this->journal->destination_account->name);
|
|
||||||
$toAccountNameLength = strlen($toAccountName);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
$searchLength = strlen($search);
|
|
||||||
|
|
||||||
// if the string to search for is longer than the account name,
|
|
||||||
// shorten the search string.
|
|
||||||
if ($searchLength > $toAccountNameLength) {
|
|
||||||
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $toAccountName . '" (' . $toAccountNameLength . '). ');
|
|
||||||
$search = substr($search, ($toAccountNameLength * -1));
|
|
||||||
$searchLength = strlen($search);
|
|
||||||
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$part = substr($toAccountName, $searchLength * -1);
|
|
||||||
|
|
||||||
if ($part == $search) {
|
|
||||||
Log::debug('"' . $toAccountName . '" ends with "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $toAccountName . '" does not end with "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,4 +61,39 @@ class ToAccountEnds implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$toAccountName = strtolower($journal->destination_account->name);
|
||||||
|
$toAccountNameLength = strlen($toAccountName);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
$searchLength = strlen($search);
|
||||||
|
|
||||||
|
// if the string to search for is longer than the account name,
|
||||||
|
// shorten the search string.
|
||||||
|
if ($searchLength > $toAccountNameLength) {
|
||||||
|
Log::debug('Search string "' . $search . '" (' . $searchLength . ') is longer than "' . $toAccountName . '" (' . $toAccountNameLength . '). ');
|
||||||
|
$search = substr($search, ($toAccountNameLength * -1));
|
||||||
|
$searchLength = strlen($search);
|
||||||
|
Log::debug('Search string is now "' . $search . '" (' . $searchLength . ') instead.');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$part = substr($toAccountName, $searchLength * -1);
|
||||||
|
|
||||||
|
if ($part == $search) {
|
||||||
|
Log::debug('"' . $toAccountName . '" ends with "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $toAccountName . '" does not end with "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class ToAccountIs implements TriggerInterface
|
class ToAccountIs implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,30 +30,10 @@ class ToAccountIs implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$toAccountName = strtolower($this->journal->destination_account->name);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
|
|
||||||
if ($toAccountName == $search) {
|
|
||||||
Log::debug('"' . $toAccountName . '" equals "' . $search . '" exactly. Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $toAccountName . '" does not equal "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,4 +61,25 @@ class ToAccountIs implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$toAccountName = strtolower($journal->destination_account->name);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
|
if ($toAccountName == $search) {
|
||||||
|
Log::debug('"' . $toAccountName . '" equals "' . $search . '" exactly. Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $toAccountName . '" does not equal "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class ToAccountStarts implements TriggerInterface
|
class ToAccountStarts implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,32 +30,10 @@ class ToAccountStarts implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$toAccountName = strtolower($this->journal->destination_account->name);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
|
|
||||||
$part = substr($toAccountName, 0, strlen($search));
|
|
||||||
|
|
||||||
if ($part == $search) {
|
|
||||||
Log::debug('"' . $toAccountName . '" starts with "' . $search . '". Return true.');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('"' . $toAccountName . '" does not start with "' . $search . '". Return false.');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,4 +61,27 @@ class ToAccountStarts implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$toAccountName = strtolower($journal->destination_account->name);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
|
$part = substr($toAccountName, 0, strlen($search));
|
||||||
|
|
||||||
|
if ($part == $search) {
|
||||||
|
Log::debug('"' . $toAccountName . '" starts with "' . $search . '". Return true.');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('"' . $toAccountName . '" does not start with "' . $search . '". Return false.');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class TransactionType implements TriggerInterface
|
class TransactionType implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,30 +30,11 @@ class TransactionType implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function triggered()
|
|
||||||
{
|
|
||||||
$type = strtolower($this->journal->transactionType->type);
|
|
||||||
$search = strtolower($this->trigger->trigger_value);
|
|
||||||
|
|
||||||
if ($type == $search) {
|
|
||||||
Log::debug('Journal is of type "' . $type . '" which matches with "' . $search . '". Return true');
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Log::debug('Journal is of type "' . $type . '" which does not match with "' . $search . '". Return false');
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -80,4 +61,24 @@ class TransactionType implements TriggerInterface
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function triggered(TransactionJournal $journal)
|
||||||
|
{
|
||||||
|
$type = strtolower($journal->transactionType->type);
|
||||||
|
$search = strtolower($this->trigger->trigger_value);
|
||||||
|
|
||||||
|
if ($type == $search) {
|
||||||
|
Log::debug('Journal is of type "' . $type . '" which matches with "' . $search . '". Return true');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Log::debug('Journal is of type "' . $type . '" which does not match with "' . $search . '". Return false');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@ namespace FireflyIII\Rules\Triggers;
|
|||||||
|
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
use FireflyIII\Models\RuleTrigger;
|
use FireflyIII\Models\RuleTrigger;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
|
||||||
use FireflyIII\Support\Domain;
|
use FireflyIII\Support\Domain;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -28,16 +27,15 @@ class TriggerFactory
|
|||||||
* Returns the trigger for the given type and journal
|
* Returns the trigger for the given type and journal
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*
|
*
|
||||||
* @return TriggerInterface
|
* @return TriggerInterface
|
||||||
*/
|
*/
|
||||||
public static function getTrigger(RuleTrigger $trigger, TransactionJournal $journal): TriggerInterface
|
public static function getTrigger(RuleTrigger $trigger): TriggerInterface
|
||||||
{
|
{
|
||||||
$triggerType = $trigger->trigger_type;
|
$triggerType = $trigger->trigger_type;
|
||||||
$class = self::getTriggerClass($triggerType);
|
$class = self::getTriggerClass($triggerType);
|
||||||
|
|
||||||
return new $class($trigger, $journal);
|
return new $class($trigger);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +43,8 @@ class TriggerFactory
|
|||||||
*
|
*
|
||||||
* @param string $triggerType
|
* @param string $triggerType
|
||||||
*
|
*
|
||||||
* @return TriggerInterface
|
* @return TriggerInterface|string
|
||||||
|
* @throws FireflyException
|
||||||
*/
|
*/
|
||||||
public static function getTriggerClass(string $triggerType): string
|
public static function getTriggerClass(string $triggerType): string
|
||||||
{
|
{
|
||||||
|
@@ -24,9 +24,8 @@ interface TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal);
|
public function __construct(RuleTrigger $trigger);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trigger is said to "match anything", or match any given transaction,
|
* A trigger is said to "match anything", or match any given transaction,
|
||||||
@@ -47,7 +46,9 @@ interface TriggerInterface
|
|||||||
public static function willMatchEverything($value = null);
|
public static function willMatchEverything($value = null);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered();
|
public function triggered(TransactionJournal $journal);
|
||||||
}
|
}
|
||||||
|
@@ -21,8 +21,8 @@ use Log;
|
|||||||
*/
|
*/
|
||||||
class UserAction implements TriggerInterface
|
class UserAction implements TriggerInterface
|
||||||
{
|
{
|
||||||
/** @var TransactionJournal */
|
|
||||||
protected $journal;
|
|
||||||
/** @var RuleTrigger */
|
/** @var RuleTrigger */
|
||||||
protected $trigger;
|
protected $trigger;
|
||||||
|
|
||||||
@@ -30,12 +30,11 @@ class UserAction implements TriggerInterface
|
|||||||
* TriggerInterface constructor.
|
* TriggerInterface constructor.
|
||||||
*
|
*
|
||||||
* @param RuleTrigger $trigger
|
* @param RuleTrigger $trigger
|
||||||
* @param TransactionJournal $journal
|
|
||||||
*/
|
*/
|
||||||
public function __construct(RuleTrigger $trigger, TransactionJournal $journal)
|
public function __construct(RuleTrigger $trigger)
|
||||||
{
|
{
|
||||||
$this->trigger = $trigger;
|
$this->trigger = $trigger;
|
||||||
$this->journal = $journal;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +62,11 @@ class UserAction implements TriggerInterface
|
|||||||
/**
|
/**
|
||||||
* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.
|
* This trigger is always triggered, because the rule that it is a part of has been pre-selected on this condition.
|
||||||
*
|
*
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function triggered()
|
public function triggered(TransactionJournal $journal)
|
||||||
{
|
{
|
||||||
Log::debug('user_action always returns true.');
|
Log::debug('user_action always returns true.');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user