2021-01-29 17:09:52 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* DiscussionTools resource loader hooks
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @ingroup Extensions
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Hooks;
|
|
|
|
|
|
|
|
use Config;
|
2021-09-07 20:51:35 +00:00
|
|
|
use ConfigFactory;
|
2021-01-29 17:09:52 +00:00
|
|
|
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
|
|
|
|
|
|
|
class ResourceLoaderHooks implements
|
|
|
|
ResourceLoaderGetConfigVarsHook
|
|
|
|
{
|
2021-09-07 20:51:35 +00:00
|
|
|
/** @var ConfigFactory */
|
|
|
|
private $configFactory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param ConfigFactory $configFactory
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
ConfigFactory $configFactory
|
|
|
|
) {
|
|
|
|
$this->configFactory = $configFactory;
|
|
|
|
}
|
|
|
|
|
2021-01-29 17:09:52 +00:00
|
|
|
/**
|
|
|
|
* Set static (not request-specific) JS configuration variables
|
|
|
|
*
|
|
|
|
* @see https://www.mediawiki.org/wiki/Manual:Hooks/ResourceLoaderGetConfigVars
|
|
|
|
* @param array &$vars Array of variables to be added into the output of the startup module
|
|
|
|
* @param string $skin Current skin name to restrict config variables to a certain skin
|
|
|
|
* @param Config $config
|
|
|
|
*/
|
2021-07-22 07:25:13 +00:00
|
|
|
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
|
2021-09-07 20:51:35 +00:00
|
|
|
$dtConfig = $this->configFactory->makeConfig( 'discussiontools' );
|
2021-01-29 17:09:52 +00:00
|
|
|
|
|
|
|
$vars['wgDTSchemaEditAttemptStepSamplingRate'] =
|
|
|
|
$dtConfig->get( 'DTSchemaEditAttemptStepSamplingRate' );
|
|
|
|
$vars['wgDTSchemaEditAttemptStepOversample'] =
|
|
|
|
$dtConfig->get( 'DTSchemaEditAttemptStepOversample' );
|
2021-12-17 16:34:23 +00:00
|
|
|
|
|
|
|
$abtest = $dtConfig->get( 'DiscussionToolsABTest' );
|
|
|
|
if ( $abtest ) {
|
|
|
|
$vars['wgDiscussionToolsABTest'] = $abtest;
|
|
|
|
}
|
2021-01-29 17:09:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|