mediawiki-extensions-Confir.../hCaptcha/includes/Hooks/ResourceLoaderHooks.php
libraryupgrader 81a524e2e9 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0

npm:
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* glob-parent: 5.1.0 → 5.1.2
  * https://npmjs.com/advisories/1751 (CVE-2020-28469)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: I57837ebf8054a2e968d207fecb3f12397c18e2a2
2021-07-22 14:24:25 +00:00

30 lines
938 B
PHP

<?php
declare( strict_types=1 );
namespace MediaWiki\Extensions\ConfirmEdit\hCaptcha\Hooks;
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
*/
public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
$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',
];
}
}
}