From 3fc6c1b6eeecec318f1cd55a23e47a91abc80ee6 Mon Sep 17 00:00:00 2001 From: Markus Date: Sun, 27 Oct 2024 18:18:27 +0100 Subject: [PATCH] refactor database in log_output_db to DI --- classes/local/output/log_output_db.php | 8 +++----- tests/local/output/log_output_db_test.php | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/classes/local/output/log_output_db.php b/classes/local/output/log_output_db.php index 85e3475..01ed72b 100644 --- a/classes/local/output/log_output_db.php +++ b/classes/local/output/log_output_db.php @@ -7,12 +7,10 @@ use stdClass; class log_output_db implements log_output { - private moodle_database $db; - public function __construct(moodle_database $db = null) { - global $DB; - $this->db = $db ?? $DB; - } + public function __construct( + private readonly moodle_database $db + ) {} /** * @throws dml_exception diff --git a/tests/local/output/log_output_db_test.php b/tests/local/output/log_output_db_test.php index 289400f..1b39490 100644 --- a/tests/local/output/log_output_db_test.php +++ b/tests/local/output/log_output_db_test.php @@ -1,5 +1,6 @@