Move ->load into App.php and other fixes

This commit is contained in:
slawkens 2025-03-16 08:41:46 +01:00
parent deb8745ca1
commit fddb18d412
4 changed files with 19 additions and 14 deletions

View File

@ -46,8 +46,6 @@ if(isset($config['gzip_output']) && $config['gzip_output'] && isset($_SERVER['HT
// event system // event system
$hooks = app()->get('hooks'); $hooks = app()->get('hooks');
$hooks->load();
$hooks->trigger(HOOK_INIT);
// twig // twig
require_once SYSTEM . 'twig.php'; require_once SYSTEM . 'twig.php';
@ -151,8 +149,7 @@ if (!isset($configDatabaseAutoMigrate) || $configDatabaseAutoMigrate) {
} }
// settings // settings
$settings = Settings::getInstance(); $settings = app()->get('settings');
$settings->load();
// csrf protection // csrf protection
$token = getSession('csrf_token'); $token = getSession('csrf_token');

View File

@ -3,8 +3,6 @@
* @var OTS_DB_MySQL $db * @var OTS_DB_MySQL $db
*/ */
use MyAAC\Cache\Cache;
$up = function () use ($db) { $up = function () use ($db) {
$db->dropTable(TABLE_PREFIX . 'hooks'); $db->dropTable(TABLE_PREFIX . 'hooks');

View File

@ -34,9 +34,7 @@ class App
$loginService = new LoginService(); $loginService = new LoginService();
$checkLogin = $loginService->checkLogin(); $checkLogin = $loginService->checkLogin();
$logged = $checkLogin['logged']; $this->accountLogged = $checkLogin['account'];
$account_logged = $checkLogin['account'];
$this->accountLogged = $account_logged;
$statusService = new StatusService(); $statusService = new StatusService();
$status = $statusService->checkStatus(); $status = $statusService->checkStatus();
@ -81,8 +79,9 @@ class App
global $template_path, $template_index; global $template_path, $template_index;
$title_full = (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName']; $title_full = (isset($title) ? $title . ' - ' : '') . $config['lua']['serverName'];
$logged = $this->isLoggedIn; global $logged, $account_logged;
$accountLogged = $this->accountLogged; $logged = $checkLogin['logged'];
$account_logged = $checkLogin['account'];
require $template_path . '/' . $template_index; require $template_path . '/' . $template_index;
@ -136,11 +135,16 @@ class App
break; break;
case 'hooks': case 'hooks':
$this->instances[$what] = new Hooks(); $this->instances[$what] = $hooks = new Hooks();
$hooks->load();
$hooks->trigger(HOOK_INIT);
break; break;
case 'settings': case 'settings':
$this->instances[$what] = Settings::getInstance(); $this->instances[$what] = $settings = Settings::getInstance();
$settings->load();
break; break;
case 'twig': case 'twig':
@ -150,6 +154,7 @@ class App
'auto_reload' => $dev_mode, 'auto_reload' => $dev_mode,
'debug' => $dev_mode 'debug' => $dev_mode
)); ));
break; break;
case 'twig-loader': case 'twig-loader':

View File

@ -9,7 +9,12 @@ class RouterService
{ {
public function handleRouting(): array public function handleRouting(): array
{ {
global $content, $logged, $db, $twig, $template_path, $template; global $content, $template_path, $template;
$db = app()->get('database');
$twig = app()->get('twig');
$logged = app()->isLoggedIn();
$account_logged = app()->getAccountLogged();
if(!isset($content[0])) { if(!isset($content[0])) {
$content = ''; $content = '';