2021-03-25 15:13:51 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare( strict_types=1 );
|
|
|
|
|
2022-03-05 15:05:22 +00:00
|
|
|
namespace MediaWiki\Extension\ConfirmEdit\hCaptcha\Hooks;
|
2021-03-25 15:13:51 +00:00
|
|
|
|
|
|
|
use Config;
|
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
|
|
|
|
|
|
|
|
class ResourceLoaderHooks implements ResourceLoaderGetConfigVarsHook {
|
|
|
|
/**
|
|
|
|
* Adds extra variables to the global config
|
|
|
|
*
|
|
|
|
* @param array &$vars Global variables object
|
|
|
|
* @param string $skin
|
|
|
|
* @param Config $config
|
|
|
|
* @return void
|
|
|
|
*/
|
2021-07-22 06:38:52 +00:00
|
|
|
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
|
2021-03-25 15:13:51 +00:00
|
|
|
$hCaptchaConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'hcaptcha' );
|
|
|
|
if ( $hCaptchaConfig->get( 'CaptchaClass' ) === 'MediaWiki\\Extensions\\ConfirmEdit\\hCaptcha\\HCaptcha' ) {
|
|
|
|
$vars['wgConfirmEditConfig'] = [
|
|
|
|
'hCaptchaSiteKey' => $hCaptchaConfig->get( 'HCaptchaSiteKey' ),
|
|
|
|
'hCaptchaScriptURL' => 'https://hcaptcha.com/1/api.js',
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|