mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Twig methods.
This commit is contained in:
@@ -118,25 +118,6 @@ class RuleController extends Controller
|
|||||||
$oldTriggers = [];
|
$oldTriggers = [];
|
||||||
$oldActions = [];
|
$oldActions = [];
|
||||||
|
|
||||||
// array of valid values for triggers.
|
|
||||||
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
|
||||||
$possibleTriggers = [];
|
|
||||||
foreach ($ruleTriggers as $key) {
|
|
||||||
if ($key != 'user_action') {
|
|
||||||
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($key, $ruleTriggers);
|
|
||||||
|
|
||||||
// array of valid values for actions
|
|
||||||
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
|
|
||||||
$possibleActions = [];
|
|
||||||
foreach ($ruleActions as $key) {
|
|
||||||
$possibleActions[$key] = trans('firefly.rule_action_' . $key . '_choice');
|
|
||||||
}
|
|
||||||
unset($key, $ruleActions);
|
|
||||||
|
|
||||||
|
|
||||||
// has old input?
|
// has old input?
|
||||||
if (Input::old()) {
|
if (Input::old()) {
|
||||||
// process old triggers.
|
// process old triggers.
|
||||||
@@ -153,7 +134,6 @@ class RuleController extends Controller
|
|||||||
'oldTrigger' => $oldTrigger,
|
'oldTrigger' => $oldTrigger,
|
||||||
'oldValue' => $oldValue,
|
'oldValue' => $oldValue,
|
||||||
'oldChecked' => $oldChecked,
|
'oldChecked' => $oldChecked,
|
||||||
'triggers' => $possibleTriggers,
|
|
||||||
'count' => $count
|
'count' => $count
|
||||||
]
|
]
|
||||||
)->render();
|
)->render();
|
||||||
@@ -185,13 +165,6 @@ class RuleController extends Controller
|
|||||||
$subTitleIcon = 'fa-clone';
|
$subTitleIcon = 'fa-clone';
|
||||||
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
$subTitle = trans('firefly.make_new_rule', ['title' => $ruleGroup->title]);
|
||||||
|
|
||||||
// mandatory field: rule triggers on update-journal or store-journal.
|
|
||||||
$journalTriggers = [
|
|
||||||
'store-journal' => trans('firefly.rule_trigger_store_journal'),
|
|
||||||
'update-journal' => trans('firefly.rule_trigger_update_journal')
|
|
||||||
];
|
|
||||||
|
|
||||||
|
|
||||||
// put previous url in session if not redirect from store (not "create another").
|
// put previous url in session if not redirect from store (not "create another").
|
||||||
if (Session::get('rules.rule.create.fromStore') !== true) {
|
if (Session::get('rules.rule.create.fromStore') !== true) {
|
||||||
Session::put('rules.rule.create.url', URL::previous());
|
Session::put('rules.rule.create.url', URL::previous());
|
||||||
@@ -201,7 +174,7 @@ class RuleController extends Controller
|
|||||||
Session::flash('gaEventAction', 'create-rule');
|
Session::flash('gaEventAction', 'create-rule');
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'rules.rule.create', compact('subTitleIcon', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroup', 'subTitle', 'journalTriggers')
|
'rules.rule.create', compact('subTitleIcon', 'oldTriggers', 'oldActions', 'triggerCount', 'actionCount', 'ruleGroup', 'subTitle')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace FireflyIII\Support\Twig;
|
namespace FireflyIII\Support\Twig;
|
||||||
|
|
||||||
|
use Config;
|
||||||
use Twig_Extension;
|
use Twig_Extension;
|
||||||
use Twig_SimpleFunction;
|
use Twig_SimpleFunction;
|
||||||
|
|
||||||
@@ -27,6 +28,34 @@ class Rule extends Twig_Extension
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$functions[] = new Twig_SimpleFunction(
|
||||||
|
'allRuleTriggers', function () {
|
||||||
|
$ruleTriggers = array_keys(Config::get('firefly.rule-triggers'));
|
||||||
|
$possibleTriggers = [];
|
||||||
|
foreach ($ruleTriggers as $key) {
|
||||||
|
if ($key != 'user_action') {
|
||||||
|
$possibleTriggers[$key] = trans('firefly.rule_trigger_' . $key . '_choice');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unset($key, $ruleTriggers);
|
||||||
|
|
||||||
|
return $possibleTriggers;
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
$functions[] = new Twig_SimpleFunction('allRuleActions', function () {
|
||||||
|
// array of valid values for actions
|
||||||
|
$ruleActions = array_keys(Config::get('firefly.rule-actions'));
|
||||||
|
$possibleActions = [];
|
||||||
|
foreach ($ruleActions as $key) {
|
||||||
|
$possibleActions[$key] = trans('firefly.rule_action_' . $key . '_choice');
|
||||||
|
}
|
||||||
|
unset($key, $ruleActions);
|
||||||
|
|
||||||
|
return $possibleActions;
|
||||||
|
});
|
||||||
|
|
||||||
return $functions;
|
return $functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user