From 3ca0014b46b4bbcefdf463e51c8a78e04b76f4f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Beyou?= Date: Thu, 1 Aug 2024 11:51:13 +0200 Subject: [PATCH] Fix deprecated class Hooks replaced by HookContainer Fixes #75 --- src/HookRegistry.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/HookRegistry.php b/src/HookRegistry.php index 2e88cfe..8958bb4 100644 --- a/src/HookRegistry.php +++ b/src/HookRegistry.php @@ -2,6 +2,7 @@ namespace SMT; +use MediaWiki\MediaWikiServices; use SMW\ApplicationFactory; use SMW\Store; use Hooks; @@ -33,8 +34,15 @@ public function __construct( Store $store, Options $options ) { * @since 1.0 */ public function register() { - foreach ( $this->handlers as $name => $callback ) { - Hooks::register( $name, $callback ); + if ( class_exists( 'MediaWiki\HookContainer\HookContainer' ) ) { + $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); + foreach ( $this->handlers as $name => $callback ) { + $hookContainer->register( $name, $callback ); + } + } else { + foreach ( $this->handlers as $name => $callback ) { + Hooks::register( $name, $callback ); + } } } @@ -46,7 +54,12 @@ public function register() { * @return boolean */ public function isRegistered( $name ) { - return Hooks::isRegistered( $name ); + if ( class_exists( 'MediaWiki\HookContainer\HookContainer' ) ) { + $hookContainer = MediaWikiServices::getInstance()->getHookContainer(); + return $hookContainer->isRegistered( $name ); + } else { + return Hooks::isRegistered( $name ); + } } /**