Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ScribuntoHooks
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 onScribuntoExternalLibraries
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
6
 onScribuntoExternalLibraryPaths
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace Capiunto;
4
5use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibrariesHook;
6use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibraryPathsHook;
7
8/**
9 * File defining the hook handlers for the Capiunto extension.
10 * All hooks from the Scribunto extension which is optional to use with this extension.
11 *
12 * @license GPL-2.0-or-later
13 *
14 * @author Marius Hoch < hoo@online.de >
15 */
16class ScribuntoHooks implements
17    ScribuntoExternalLibrariesHook,
18    ScribuntoExternalLibraryPathsHook
19{
20
21    /**
22     * External Lua library 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            return;
30        }
31
32        $extraLibraries['capiunto'] = [
33            'class' => LuaLibrary::class,
34            'deferLoad' => true
35        ];
36    }
37
38    /**
39     * External Lua library paths for Scribunto
40     *
41     * @param string $engine
42     * @param array &$extraLibraryPaths
43     */
44    public function onScribuntoExternalLibraryPaths(
45        string $engine,
46        array &$extraLibraryPaths
47    ): void {
48        if ( $engine !== 'lua' ) {
49            return;
50        }
51
52        // Path containing pure Lua libraries that don't need to interact with PHP
53        $extraLibraryPaths[] = __DIR__ . '/lua/pure';
54    }
55
56}