refactor(pages): replace superglobals with request/session abstractions

This commit is contained in:
2026-03-06 11:28:22 +01:00
parent ebf15081e1
commit 205da203cc
87 changed files with 368 additions and 127 deletions

View File

@@ -1,6 +1,7 @@
<?php
use MintyPHP\Buffer;
use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\I18n;
use MintyPHP\Repository\Auth\PasswordResetRepository;
use MintyPHP\Repository\Auth\RememberTokenRepository;
@@ -10,6 +11,9 @@ use MintyPHP\Service\CustomField\UserCustomFieldValueService;
use MintyPHP\Support\Flash;
use MintyPHP\Support\Guard;
$sessionStore = app(SessionStoreInterface::class);
$session = $sessionStore->all();
Guard::requireLogin();
$request = requestInput();
$userAccountService = app(\MintyPHP\Service\User\UserAccountService::class);
@@ -31,7 +35,7 @@ $departmentService = app(\MintyPHP\Service\Org\DepartmentService::class);
$passwordMinLength = $userPasswordPolicyService->minLength();
$passwordHints = $userPasswordPolicyService->hints();
$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
$currentUserId = (int) ($session['user']['id'] ?? 0);
$uuid = trim((string) ($id ?? ''));
$user = $uuid !== '' ? $userAccountService->findByUuid($uuid) : null;
if (!$user) {
@@ -269,10 +273,18 @@ if ($request->hasBody('email')) {
if ($currentUserId === $userId && isset($form['theme'])) {
$themes = appThemes();
$themeValue = strtolower(trim((string) ($form['theme'] ?? '')));
$_SESSION['user']['theme'] = isset($themes[$themeValue]) ? $themeValue : appDefaultTheme();
$userSession = $sessionStore->get('user', []);
if (is_array($userSession)) {
$userSession['theme'] = isset($themes[$themeValue]) ? $themeValue : appDefaultTheme();
$sessionStore->set('user', $userSession);
}
}
if ($currentUserId === $userId && isset($form['locale'])) {
$_SESSION['user']['locale'] = $form['locale'];
$userSession = $sessionStore->get('user', []);
if (is_array($userSession)) {
$userSession['locale'] = $form['locale'];
$sessionStore->set('user', $userSession);
}
I18n::$locale = $form['locale'];
}
if (!$errorBag->hasAny()) {