Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
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 / 8
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 / 7
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 Config;
13use 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        $vars['wgDTSchemaEditAttemptStepSamplingRate'] =
38            $this->config->get( 'DTSchemaEditAttemptStepSamplingRate' );
39        $vars['wgDTSchemaEditAttemptStepOversample'] =
40            $this->config->get( 'DTSchemaEditAttemptStepOversample' );
41
42        $abtest = $this->config->get( 'DiscussionToolsABTest' );
43        if ( $abtest ) {
44            $vars['wgDiscussionToolsABTest'] = $abtest;
45        }
46    }
47
48}