Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
ScribuntoHooks | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
onScribuntoExternalLibraries | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
onScribuntoExternalLibraryPaths | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace ArticlePlaceholder; |
4 | |
5 | use ArticlePlaceholder\Lua\ArticlePlaceholderLibrary; |
6 | use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibrariesHook; |
7 | use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibraryPathsHook; |
8 | |
9 | /** |
10 | * File defining the hook handlers for the ArticlePlaceholder extension. |
11 | * All hooks from the Scribunto extension which is optional to use with this extension. |
12 | * |
13 | * @license GPL-2.0-or-later |
14 | * @author Lucie-Aimée Kaffee |
15 | */ |
16 | class ScribuntoHooks implements |
17 | ScribuntoExternalLibrariesHook, |
18 | ScribuntoExternalLibraryPathsHook |
19 | { |
20 | |
21 | /** |
22 | * External Lua libraries for Scribunto |
23 | * |
24 | * @param string $engine |
25 | * @param array[] &$extraLibraries |
26 | */ |
27 | public function onScribuntoExternalLibraries( string $engine, array &$extraLibraries ): void { |
28 | if ( $engine === 'lua' ) { |
29 | $extraLibraries['mw.ext.articlePlaceholder.entityRenderer'] = [ |
30 | 'class' => ArticlePlaceholderLibrary::class, |
31 | 'deferLoad' => true, |
32 | ]; |
33 | } |
34 | } |
35 | |
36 | /** |
37 | * External Lua library paths for Scribunto |
38 | * |
39 | * @param string $engine |
40 | * @param string[] &$extraLibraryPaths |
41 | */ |
42 | public function onScribuntoExternalLibraryPaths( |
43 | string $engine, |
44 | array &$extraLibraryPaths |
45 | ): void { |
46 | if ( $engine === 'lua' ) { |
47 | $extraLibraryPaths[] = __DIR__ . '/Lua'; |
48 | } |
49 | } |
50 | |
51 | } |