From eaeabd885030b7f3ca8cd68a664be22a7ce56dc2 Mon Sep 17 00:00:00 2001 From: objecttothis Date: Sun, 20 Nov 2022 21:03:37 +0400 Subject: [PATCH] Fixing runtime bugs - instantiating Load_config - Added todos --- app/Config/Events.php | 8 +++++--- app/Events/Load_config.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Config/Events.php b/app/Config/Events.php index fc2f6279e..b5a7fd774 100644 --- a/app/Config/Events.php +++ b/app/Config/Events.php @@ -2,6 +2,7 @@ namespace Config; +use App\Events\Load_config; use CodeIgniter\Events\Events; use CodeIgniter\Exceptions\FrameworkException; @@ -52,8 +53,9 @@ Events::on('pre_system', function () } }); -Events::on('post_controller_constructor', ['Load_config', 'load_config']); +$config = new Load_config(); //TODO: Not 100% sure this is the best way to do this, but without instantiating the class, the event engine tries to run the function as if it were static. +Events::on('post_controller_constructor', [$config, 'load_config']); -Events::on('post_controller', ['Db_log', 'db_log_queries']); +Events::on('post_controller', ['\App\Events\Db_log', 'db_log_queries']); -Events::on('pre_controller', ['Method', 'validate_method']); +Events::on('pre_controller', ['\App\Events\Method', 'validate_method']); diff --git a/app/Events/Load_config.php b/app/Events/Load_config.php index f5c5c7708..65e68b84f 100644 --- a/app/Events/Load_config.php +++ b/app/Events/Load_config.php @@ -23,7 +23,7 @@ class Load_config { //Migrations $migration_config = config('Migrations'); - $migration = new My_Migration($migration_config); + $migration = new MY_Migration($migration_config); //TODO: This errors out. We need to figure out how to automatically check and run latest migrations in CI4... the CI3 method is different. $this->session = session();