Load hooks before twig, add new hooks: HOOK_TWIG + HOOK_INIT

This commit is contained in:
slawkens 2025-05-16 07:42:50 +02:00
parent 26b2c472cc
commit 5726c9fa94
6 changed files with 10 additions and 10 deletions

View File

@ -34,11 +34,6 @@ if(config('env') === 'dev') {
error_reporting(E_ALL);
}
// event system
require_once SYSTEM . 'hooks.php';
$hooks = new Hooks();
$hooks->load();
require SYSTEM . 'status.php';
require SYSTEM . 'login.php';
require SYSTEM . 'migrate.php';

View File

@ -193,10 +193,6 @@ define('PAGE', $page);
$template_place_holders = array();
// event system
require_once SYSTEM . 'hooks.php';
$hooks = new Hooks();
$hooks->load();
require_once SYSTEM . 'login.php';
require_once SYSTEM . 'status.php';

View File

@ -8,7 +8,6 @@ if(PHP_SAPI !== 'cli') {
require_once __DIR__ . '/../../common.php';
require_once SYSTEM . 'functions.php';
require_once SYSTEM . 'init.php';
require_once SYSTEM . 'hooks.php';
if($argc !== 2) {
echo 'This command expects one parameter: zip file name (plugin)' . PHP_EOL;

View File

@ -10,6 +10,7 @@
defined('MYAAC') or die('Direct access not allowed!');
$i = 0;
define('HOOK_INIT', ++$i);
define('HOOK_STARTUP', ++$i);
define('HOOK_BEFORE_PAGE', ++$i);
define('HOOK_AFTER_PAGE', ++$i);
@ -61,6 +62,7 @@ define('HOOK_ACCOUNT_MANAGE_BEFORE_ACCOUNT_LOGS', ++$i);
define('HOOK_ACCOUNT_MANAGE_BEFORE_CHARACTERS', ++$i);
define('HOOK_EMAIL_CONFIRMED', ++$i);
define('HOOK_GUILDS_AFTER_INVITED_CHARACTERS', ++$i);
define('HOOK_TWIG', ++$i);
define('HOOK_FIRST', HOOK_STARTUP);
define('HOOK_LAST', $i);

View File

@ -124,6 +124,12 @@ require_once SYSTEM . 'libs/pot/OTS.php';
$ots = POT::getInstance();
require_once SYSTEM . 'database.php';
// event system
require_once SYSTEM . 'hooks.php';
$hooks = new Hooks();
$hooks->load();
$hooks->trigger(HOOK_INIT);
// twig
require_once SYSTEM . 'twig.php';

View File

@ -83,3 +83,5 @@ $filter = new TwigFilter('urlencode', function ($s) {
$twig->addFilter($filter);
unset($function, $filter);
$hooks->trigger(HOOK_TWIG, ['twig' => $twig, 'twig_loader' => $twig_loader]);