MDL-81456 core: Use DI for all hook access

Using DI for all hook access means that it becomes significantly easier
to mock hooks and callbacks for unit testing without fundamentally
altering the structure of the code purely for the purposes of unit
testing.
This commit is contained in:
Andrew Nicols
2024-04-08 09:35:41 +08:00
parent 26649f5750
commit 2b49ad42f5
17 changed files with 89 additions and 42 deletions
+1 -1
View File
@@ -91,7 +91,7 @@ class hook_list_table extends flexible_table {
*/
public function out(): void {
// All hook consumers referenced from the db/hooks.php files.
$hookmanager = \core\hook\manager::get_instance();
$hookmanager = \core\di::get(\core\hook\manager::class);
$allhooks = (array)$hookmanager->get_all_callbacks();
// Add any unused hooks.