mediawiki-extensions-Parser.../includes/LuaLibrary.php
Fomafix 4bcd4ac8cb Use namespaced PHP classes for extension Scribunto
This change depends on the Scribunto change
I74fd43f7920c8772e9078f745ac6062d5461a7f1 included in REL1_40.

Depends-On: I74fd43f7920c8772e9078f745ac6062d5461a7f1
Change-Id: Id4156a8934583971df6b449d13f3d8eb6cee6368
2024-10-13 12:52:04 +00:00

30 lines
717 B
PHP

<?php
namespace MediaWiki\Extension\ParserFunctions;
use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase;
use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LuaError;
class LuaLibrary extends LibraryBase {
public function register() {
$lib = [
'expr' => [ $this, 'expr' ],
];
return $this->getEngine()->registerInterface(
__DIR__ . '/mw.ext.ParserFunctions.lua', $lib, []
);
}
public function expr( $expression = null ) {
$this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' );
try {
$exprParser = new ExprParser();
return [ $exprParser->doExpression( $expression ) ];
} catch ( ExprError $e ) {
throw new LuaError( $e->getMessage() );
}
}
}