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
$hooks = app()->get('hooks');
$hooks->load();
$hooks->trigger(HOOK_INIT);
// twig
require_once SYSTEM . 'twig.php';
@ -151,8 +149,7 @@ if (!isset($configDatabaseAutoMigrate) || $configDatabaseAutoMigrate) {
}
// settings
$settings = Settings::getInstance();
$settings->load();
$settings = app()->get('settings');
// csrf protection
$token = getSession('csrf_token');

View File

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

View File

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

View File

@ -9,7 +9,12 @@ class RouterService
{
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])) {
$content = '';