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
ResourceLoaderHooks
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
12
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
 onResourceLoaderGetConfigVars
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * DiscussionTools resource loader hooks
4 *
5 * @file
6 * @ingroup Extensions
7 * @license MIT
8 */
9
10namespace MediaWiki\Extension\DiscussionTools\Hooks;
11
12use MediaWiki\Config\Config;
13use MediaWiki\Config\ConfigFactory;
14use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
15
16class ResourceLoaderHooks implements
17    ResourceLoaderGetConfigVarsHook
18{
19
20    private Config $config;
21
22    public function __construct(
23        ConfigFactory $configFactory
24    ) {
25        $this->config = $configFactory->makeConfig( 'discussiontools' );
26    }
27
28    /**
29     * Set static (not request-specific) JS configuration variables
30     *
31     * @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
32     * @param array &$vars Array of variables to be added into the output of the startup module
33     * @param string $skin Current skin name to restrict config variables to a certain skin
34     * @param Config $config
35     */
36    public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
37        $abtest = $this->config->get( 'DiscussionToolsABTest' );
38        if ( $abtest ) {
39            $vars['wgDiscussionToolsABTest'] = $abtest;
40        }
41    }
42
43}