From 903034de23bdfb1fae2d2937153008a700dd3283 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Sun, 4 Jun 2023 20:38:52 +0200 Subject: [PATCH] Create HookRunner class and the hook handler interface Bug: T315823 Change-Id: I09c45ed939e103e6edb3a76623687574dcf0206f --- includes/Hooks.php | 3 +- includes/Hooks/HookRunner.php | 31 +++++++++++++++++++ includes/Hooks/SkinMinervaOptionsInitHook.php | 22 +++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 includes/Hooks/HookRunner.php create mode 100644 includes/Hooks/SkinMinervaOptionsInitHook.php diff --git a/includes/Hooks.php b/includes/Hooks.php index 7a7b473b0..714fda1d9 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -29,6 +29,7 @@ use MediaWiki\Hook\FetchChangesListHook; use MediaWiki\Hook\OutputPageBodyAttributesHook; use MediaWiki\Hook\UserLogoutCompleteHook; use MediaWiki\MediaWikiServices; +use MediaWiki\Minerva\Hooks\HookRunner; use MediaWiki\Minerva\Skins\SkinMinerva; use MediaWiki\Minerva\Skins\SkinUserPageHelper; use MediaWiki\ResourceLoader\Context; @@ -320,7 +321,7 @@ class Hooks implements ), SkinOptions::TABS_ON_SPECIALS => true, ] ); - $services->getHookContainer()->run( 'SkinMinervaOptionsInit', [ $skin, $skinOptions ] ); + ( new HookRunner( $services->getHookContainer() ) )->onSkinMinervaOptionsInit( $skin, $skinOptions ); } } diff --git a/includes/Hooks/HookRunner.php b/includes/Hooks/HookRunner.php new file mode 100644 index 000000000..4e7a8101b --- /dev/null +++ b/includes/Hooks/HookRunner.php @@ -0,0 +1,31 @@ +hookContainer = $hookContainer; + } + + /** + * @inheritDoc + */ + public function onSkinMinervaOptionsInit( Skin $skin, SkinOptions $skinOptions ) { + return $this->hookContainer->run( + 'SkinMinervaOptionsInit', + [ $skin, $skinOptions ] + ); + } +} diff --git a/includes/Hooks/SkinMinervaOptionsInitHook.php b/includes/Hooks/SkinMinervaOptionsInitHook.php new file mode 100644 index 000000000..9d4f7e9e0 --- /dev/null +++ b/includes/Hooks/SkinMinervaOptionsInitHook.php @@ -0,0 +1,22 @@ +