Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 4
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 / 4
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onScribuntoExternalLibraries
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace JsonConfig;
4
5use MediaWiki\Config\Config;
6use MediaWiki\Extension\Scribunto\Hooks\ScribuntoExternalLibrariesHook;
7
8/**
9 * Hook handlers for JsonConfig extension.
10 * All hooks from the Scribunto extension which is optional to use with this extension.
11 *
12 * @file
13 * @ingroup Extensions
14 * @ingroup JsonConfig
15 * @license GPL-2.0-or-later
16 */
17class ScribuntoHooks implements
18    ScribuntoExternalLibrariesHook
19{
20    private Config $config;
21
22    public function __construct(
23        Config $config
24    ) {
25        $this->config = $config;
26    }
27
28    /**
29     * @param string $engine
30     * @param string[] &$extraLibraries
31     */
32    public function onScribuntoExternalLibraries( string $engine, array &$extraLibraries ): void {
33        $enableLuaSupport = $this->config->get( 'JsonConfigEnableLuaSupport' );
34        if ( $enableLuaSupport && $engine == 'lua' ) {
35            $extraLibraries['mw.ext.data'] = JCLuaLibrary::class;
36        }
37    }
38}