MediaWiki  1.34.4
LuaLibrary.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
9  public function register() {
10  $lib = [
11  'expr' => [ $this, 'expr' ],
12  ];
13 
14  return $this->getEngine()->registerInterface(
15  __DIR__ . '/mw.ext.ParserFunctions.lua', $lib, []
16  );
17  }
18 
19  public function expr( $expression = null ) {
20  $this->checkType( 'mw.ext.ParserFunctions.expr', 1, $expression, 'string' );
21  try {
22  $exprParser = new ExprParser();
23  return [ $exprParser->doExpression( $expression ) ];
24  } catch ( ExprError $e ) {
25  throw new Scribunto_LuaError( $e->getMessage() );
26  }
27  }
28 
29 }
Scribunto_LuaError
Definition: LuaCommon.php:992
MediaWiki\Extensions\ParserFunctions\ExprParser
Definition: ExprParser.php:71
MediaWiki\Extensions\ParserFunctions\LuaLibrary\expr
expr( $expression=null)
Definition: LuaLibrary.php:19
Scribunto_LuaLibraryBase\getEngine
getEngine()
Get the engine.
Definition: LibraryBase.php:56
Scribunto_LuaLibraryBase\checkType
checkType( $name, $argIdx, $arg, $expectType)
Check the type of a variable.
Definition: LibraryBase.php:141
Scribunto_LuaLibraryBase
This class provides some basic services that Lua libraries will probably need.
Definition: LibraryBase.php:27
MediaWiki\Extensions\ParserFunctions
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...
Definition: ExprError.php:19
MediaWiki\Extensions\ParserFunctions\ExprError
Definition: ExprError.php:24
MediaWiki\Extensions\ParserFunctions\LuaLibrary
Definition: LuaLibrary.php:8