mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ParserFunctions
synced 2024-11-14 11:18:47 +00:00
Use HookHandlers for Scribunto hook
Cannot use the interface as the required version is not reached yet. Cannot bump due to use in fundraising Bug: T271022 Change-Id: I78771f948d4d1e03fc7565525f562c61af9d749a
This commit is contained in:
parent
67df7364be
commit
72e956c82a
|
@ -33,7 +33,7 @@
|
|||
"Hooks": {
|
||||
"ParserTestGlobals": "ParserFunctionsHookHandler",
|
||||
"ParserFirstCallInit": "ParserFunctionsHookHandler",
|
||||
"ScribuntoExternalLibraries": "MediaWiki\\Extension\\ParserFunctions\\Hooks::onScribuntoExternalLibraries"
|
||||
"ScribuntoExternalLibraries": "ParserFunctionsScribuntoHookHandler"
|
||||
},
|
||||
"HookHandlers": {
|
||||
"ParserFunctionsHookHandler": {
|
||||
|
@ -41,6 +41,9 @@
|
|||
"services": [
|
||||
"MainConfig"
|
||||
]
|
||||
},
|
||||
"ParserFunctionsScribuntoHookHandler": {
|
||||
"class": "MediaWiki\\Extension\\ParserFunctions\\ScribuntoHooks"
|
||||
}
|
||||
},
|
||||
"AutoloadNamespaces": {
|
||||
|
|
|
@ -67,18 +67,4 @@ class Hooks implements
|
|||
$parser->setFunctionHook( 'urldecode', [ ParserFunctions::class, 'runUrlDecode' ] );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers ParserFunctions' lua function with Scribunto
|
||||
*
|
||||
* @see https://www.mediawiki.org/wiki/Extension:Scribunto/ScribuntoExternalLibraries
|
||||
*
|
||||
* @param string $engine
|
||||
* @param string[] &$extraLibraries
|
||||
*/
|
||||
public static function onScribuntoExternalLibraries( $engine, array &$extraLibraries ) {
|
||||
if ( $engine === 'lua' ) {
|
||||
$extraLibraries['mw.ext.ParserFunctions'] = LuaLibrary::class;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
26
includes/ScribuntoHooks.php
Normal file
26
includes/ScribuntoHooks.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\ParserFunctions;
|
||||
|
||||
/**
|
||||
* Hooks from Scribunto extension,
|
||||
* which is optional to use with this extension.
|
||||
* TODO: Implement interface MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibrariesHook
|
||||
* when extension requirement is MediaWiki 1.41+
|
||||
*/
|
||||
class ScribuntoHooks {
|
||||
|
||||
/**
|
||||
* Registers ParserFunctions' lua function with Scribunto
|
||||
*
|
||||
* @see https://www.mediawiki.org/wiki/Extension:Scribunto/ScribuntoExternalLibraries
|
||||
*
|
||||
* @param string $engine
|
||||
* @param string[] &$extraLibraries
|
||||
*/
|
||||
public function onScribuntoExternalLibraries( string $engine, array &$extraLibraries ) {
|
||||
if ( $engine === 'lua' ) {
|
||||
$extraLibraries['mw.ext.ParserFunctions'] = LuaLibrary::class;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue