mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Merge remote-tracking branch 'upstream/main' into feat/expression-engine
This commit is contained in:
@@ -30,12 +30,9 @@ use FireflyIII\Support\Domain;
|
||||
use FireflyIII\TransactionRules\Actions\ActionInterface;
|
||||
use FireflyIII\TransactionRules\Expressions\ActionExpressionEvaluator;
|
||||
use FireflyIII\TransactionRules\Factory\ExpressionLanguageFactory;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* Class ActionFactory can create actions.
|
||||
*
|
||||
|
||||
*/
|
||||
class ActionFactory
|
||||
{
|
||||
@@ -48,21 +45,17 @@ class ActionFactory
|
||||
* with value "Groceries" this method will return a corresponding SetCategory object preset
|
||||
* to "Groceries". Any transaction journal then fed to this object will have its category changed.
|
||||
*
|
||||
* @param RuleAction $action
|
||||
*
|
||||
* @return ActionInterface
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function getAction(RuleAction $action): ActionInterface
|
||||
{
|
||||
$class = self::getActionClass($action->action_type);
|
||||
Log::debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class));
|
||||
app('log')->debug(sprintf('self::getActionClass("%s") = "%s"', $action->action_type, $class));
|
||||
|
||||
$expressionLanguage = ExpressionLanguageFactory::get();
|
||||
$expressionEvaluator = new ActionExpressionEvaluator($expressionLanguage, $action->action_value);
|
||||
|
||||
return new $class($action, $expressionEvaluator);
|
||||
return new $class($action, $expressionEvaluator); // @phpstan-ignore-line
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,10 +63,6 @@ class ActionFactory
|
||||
* that will match the given action type (ie. "change_category") to the matching class name
|
||||
* (SetCategory) using the configuration (firefly.php).
|
||||
*
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public static function getActionClass(string $actionType): string
|
||||
@@ -84,7 +73,7 @@ class ActionFactory
|
||||
throw new FireflyException('No such action exists ("' . e($actionType) . '").');
|
||||
}
|
||||
|
||||
$class = $actionTypes[$actionType];
|
||||
$class = $actionTypes[$actionType];
|
||||
if (!class_exists($class)) {
|
||||
throw new FireflyException('Could not instantiate class for rule action type "' . e($actionType) . '" (' . e($class) . ').');
|
||||
}
|
||||
@@ -94,8 +83,6 @@ class ActionFactory
|
||||
|
||||
/**
|
||||
* Returns a map with actiontypes, mapped to the class representing that type.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function getActionTypes(): array
|
||||
{
|
||||
|
Reference in New Issue
Block a user