Conditionally register popup RestRoute using ExtensionFunctions

Bug: T362027
Change-Id: Id1329c72b81372468a98da3b47b101302c07b40d
(cherry picked from commit 4c2401961f)
This commit is contained in:
Reedy 2024-04-07 21:15:52 +01:00
parent 9e0699f2b9
commit 4c9eaed7a3
3 changed files with 23 additions and 13 deletions

View file

@ -34,6 +34,9 @@
"MathAlias": "Math.alias.php", "MathAlias": "Math.alias.php",
"MathAliasNoTranslate": "Math.alias.noTranslate.php" "MathAliasNoTranslate": "Math.alias.noTranslate.php"
}, },
"ExtensionFunctions": [
"MediaWiki\\Extension\\Math\\Hooks::onExtensionFunctions"
],
"HookHandlers": { "HookHandlers": {
"ParserHooksHandler": { "ParserHooksHandler": {
"class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler", "class": "MediaWiki\\Extension\\Math\\HookHandlers\\ParserHooksHandler",
@ -388,18 +391,5 @@
"ServiceWiringFiles": [ "ServiceWiringFiles": [
"ServiceWiring.php" "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 "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

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