Conditionally register popup RestRoute using ExtensionFunctions

Bug: T362027
Change-Id: Id1329c72b81372468a98da3b47b101302c07b40d
This commit is contained in:
Reedy 2024-04-07 21:15:52 +01:00
parent 81dedc1909
commit 4c2401961f
3 changed files with 23 additions and 13 deletions

View file

@ -35,6 +35,9 @@
"MathAliasNoTranslate": "Math.alias.noTranslate.php"
},
"callback": "MediaWiki\\Extension\\Math\\Hooks::onConfig",
"ExtensionFunctions": [
"MediaWiki\\Extension\\Math\\Hooks::onExtensionFunctions"
],
"HookHandlers": {
"ParserHooksHandler": {
"class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler",
@ -368,18 +371,5 @@
"ServiceWiringFiles": [
"ServiceWiring.php"
],
"RestRoutes": [
{
"path": "/math/v0/popup/html/{qid}",
"method": "GET",
"class": "MediaWiki\\Extension\\Math\\Rest\\Popup",
"services": [
"Math.WikibaseConnector",
"LanguageFactory",
"LanguageNameUtils",
"TitleFactory"
]
}
],
"manifest_version": 2
}

13
popupRestRoutes.json Normal file
View file

@ -0,0 +1,13 @@
[
{
"path": "/math/v0/popup/html/{qid}",
"method": "GET",
"class": "MediaWiki\\Extension\\Math\\Rest\\Popup",
"services": [
"Math.WikibaseConnector",
"LanguageFactory",
"LanguageNameUtils",
"TitleFactory"
]
}
]

View file

@ -81,6 +81,13 @@ class Hooks implements
}
}
public static function onExtensionFunctions() {
if ( ExtensionRegistry::getInstance()->isLoaded( 'WikibaseClient' ) ) {
global $wgRestAPIAdditionalRouteFiles;
$wgRestAPIAdditionalRouteFiles[] = dirname( __DIR__ ) . '/popupRestRoutes.json';
}
}
/**
* MaintenanceRefreshLinksInit handler; optimize settings for refreshLinks batch job.
*