Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ScribuntoHooks
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 onScribuntoExternalLibraries
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 onScribuntoExternalLibraryPaths
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace ArticlePlaceholder;
4
5use ArticlePlaceholder\Lua\Scribunto_LuaArticlePlaceholderLibrary;
6use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibrariesHook;
7use 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 */
16class 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' => Scribunto_LuaArticlePlaceholderLibrary::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}