Rearrange some code.

This commit is contained in:
James Cole
2025-09-26 05:33:35 +02:00
parent 66d09450d3
commit 08879d31ba
19 changed files with 407 additions and 416 deletions

View File

@@ -32,10 +32,9 @@ use FireflyIII\Support\Binder\AccountList;
use FireflyIII\User;
use Illuminate\Contracts\Validation\Validator as ValidatorContract;
use Illuminate\Routing\Route;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Route as RouteFacade;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Route as RouteFacade;
use Illuminate\Support\Facades\Validator;
use function Safe\parse_url;
/**
@@ -67,7 +66,7 @@ trait RequestInformation
'type' => $triggerInfo['type'] ?? '',
'value' => $triggerInfo['value'] ?? '',
'prohibited' => $triggerInfo['prohibited'] ?? false,
'stop_processing' => 1 === (int) ($triggerInfo['stop_processing'] ?? '0'),
'stop_processing' => 1 === (int)($triggerInfo['stop_processing'] ?? '0'),
];
$current = RuleFormRequest::replaceAmountTrigger($current);
$triggers[] = $current;
@@ -85,13 +84,13 @@ trait RequestInformation
$page = $this->getPageName();
$specificPage = $this->getSpecificPageName();
// indicator if user has seen the help for this page ( + special page):
$key = sprintf('shown_demo_%s%s', $page, $specificPage);
$key = sprintf('shown_demo_%s%s', $page, $specificPage);
// is there an intro for this route?
$intro = config(sprintf('intro.%s', $page)) ?? [];
$specialIntro = config(sprintf('intro.%s%s', $page, $specificPage)) ?? [];
// some routes have a "what" parameter, which indicates a special page:
$shownDemo = true;
$shownDemo = true;
// both must be array and either must be > 0
if (count($intro) > 0 || count($specialIntro) > 0) {
$shownDemo = app('preferences')->get($key, false)->data;
@@ -128,7 +127,7 @@ trait RequestInformation
$start = session('start', today(config('app.timezone'))->startOfMonth());
/** @var Carbon $end */
$end = session('end', today(config('app.timezone'))->endOfMonth());
$end = session('end', today(config('app.timezone'))->endOfMonth());
if ($start->greaterThanOrEqualTo($date) && $end->greaterThanOrEqualTo($date)) {
return true;
}
@@ -146,20 +145,20 @@ trait RequestInformation
final protected function parseAttributes(array $attributes): array // parse input + return result
{
$attributes['location'] ??= '';
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
$attributes['accounts'] = AccountList::routeBinder($attributes['accounts'] ?? '', new Route('get', '', []));
$date = Carbon::createFromFormat('Ymd', $attributes['startDate']);
if (!$date instanceof Carbon) {
$date = today(config('app.timezone'));
}
$date->startOfMonth();
$attributes['startDate'] = $date;
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
$date2 = Carbon::createFromFormat('Ymd', $attributes['endDate']);
if (!$date2 instanceof Carbon) {
$date2 = today(config('app.timezone'));
}
$date2->endOfDay();
$attributes['endDate'] = $date2;
$attributes['endDate'] = $date2;
return $attributes;
}
@@ -172,11 +171,11 @@ trait RequestInformation
final protected function validatePassword(User $user, string $current, string $new): bool // get request info
{
if (!Hash::check($current, $user->password)) {
throw new ValidationException((string) trans('firefly.invalid_current_password'));
throw new ValidationException((string)trans('firefly.invalid_current_password'));
}
if ($current === $new) {
throw new ValidationException((string) trans('firefly.should_change'));
throw new ValidationException((string)trans('firefly.should_change'));
}
return true;