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,10 +1,14 @@
<?php
use MintyPHP\Http\Request;
use MintyPHP\Http\SessionStoreInterface;
use MintyPHP\Router;
use MintyPHP\Session;
use MintyPHP\Support\Guard;
$sessionStore = app(SessionStoreInterface::class);
$session = $sessionStore->all();
Guard::requireLogin();
$userAccountService = app(\MintyPHP\Service\User\UserAccountService::class);
$errorBag = formErrors();
@@ -24,7 +28,7 @@ if (!Session::checkCsrfToken()) {
return;
}
$userId = (int) ($_SESSION['user']['id'] ?? 0);
$userId = (int) ($session['user']['id'] ?? 0);
if ($userId <= 0) {
http_response_code(401);
if (Request::wantsJson()) {
@@ -70,7 +74,11 @@ if (!$updated) {
return;
}
$_SESSION['user']['theme'] = $theme;
$userSession = $sessionStore->get('user', []);
if (is_array($userSession)) {
$userSession['theme'] = $theme;
$sessionStore->set('user', $userSession);
}
if (Request::wantsJson()) {
Router::json(['ok' => true, 'theme' => $theme]);