Avoid duplicate loading of hooks

This commit is contained in:
slawkens 2024-01-28 23:08:37 +01:00
parent 5d741944f7
commit b517a12f8a
3 changed files with 2 additions and 10 deletions

View File

@ -10,10 +10,6 @@ require SYSTEM . 'functions.php';
require SYSTEM . 'init.php'; require SYSTEM . 'init.php';
require SYSTEM . 'login.php'; require SYSTEM . 'login.php';
// event system
$hooks = new Hooks();
$hooks->load();
if(!admin()) { if(!admin()) {
http_response_code(500); http_response_code(500);
die('Access denied.'); die('Access denied.');

View File

@ -7,12 +7,7 @@ use Symfony\Component\Console\Command\Command as SymfonyCommand;
class Command extends SymfonyCommand class Command extends SymfonyCommand
{ {
protected Hooks $hooks;
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
$this->hooks = new Hooks();
$this->hooks->load();
} }
} }

View File

@ -19,7 +19,8 @@ class CronjobCommand extends Command
// Create a new scheduler // Create a new scheduler
$scheduler = new Scheduler(); $scheduler = new Scheduler();
$this->hooks->trigger(HOOK_CRONJOB, ['scheduler' => $scheduler]); global $hooks;
$hooks->trigger(HOOK_CRONJOB, ['scheduler' => $scheduler]);
// Let the scheduler execute jobs which are due. // Let the scheduler execute jobs which are due.
$scheduler->run(); $scheduler->run();