From ec3e5e27feefc2e8f38e8467486de852c699442f Mon Sep 17 00:00:00 2001 From: Reedy Date: Sun, 21 Aug 2022 17:52:27 +0100 Subject: [PATCH] Switch to HookHandlers Bug: T271010 Change-Id: Ie248342d4deb3520d284fac9c3ead17f7dee3de4 --- includes/Hooks.php | 14 +++++++++++--- skin.json | 9 +++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index 284e56e..a28420d 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -22,11 +22,19 @@ namespace MonoBook; +use MediaWiki\Hook\OutputPageBodyAttributesHook; +use MediaWiki\Hook\SkinTemplateNavigation__UniversalHook; use OutputPage; use Skin; use SkinTemplate; -class Hooks { +/** + * @phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName + */ +class Hooks implements + OutputPageBodyAttributesHook, + SkinTemplateNavigation__UniversalHook +{ /** * Add the "monobook-capitalize-all-nouns" CSS class to the element for German * (de) and various languages which have German set as a fallback language, such @@ -38,7 +46,7 @@ class Hooks { * @param Skin $skin * @param array &$bodyAttrs Pre-existing attributes for the element */ - public static function onOutputPageBodyAttributes( OutputPage $out, Skin $skin, &$bodyAttrs ) { + public function onOutputPageBodyAttributes( $out, $skin, &$bodyAttrs ): void { $lang = $skin->getLanguage(); if ( $skin->getSkinName() === 'monobook' && ( @@ -56,7 +64,7 @@ class Hooks { * @param SkinTemplate $skin * @param array &$content_navigation */ - public static function onSkinTemplateNavigationUniversal( SkinTemplate $skin, array &$content_navigation ) { + public function onSkinTemplateNavigation__Universal( $skin, &$content_navigation ): void { $title = $skin->getTitle(); if ( $skin->getSkinName() === 'monobook' ) { $tabs = []; diff --git a/skin.json b/skin.json index 996ab0d..afa4e3d 100644 --- a/skin.json +++ b/skin.json @@ -47,9 +47,14 @@ "SkinLessImportPaths": { "monobook": "resources/mediawiki.less" }, + "HookHandlers": { + "main": { + "class": "MonoBook\\Hooks" + } + }, "Hooks": { - "OutputPageBodyAttributes": "MonoBook\\Hooks::onOutputPageBodyAttributes", - "SkinTemplateNavigation::Universal": "MonoBook\\Hooks::onSkinTemplateNavigationUniversal" + "OutputPageBodyAttributes": "main", + "SkinTemplateNavigation::Universal": "main" }, "MessagesDirs": { "MonoBook": [