Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Hooks
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 onResourceLoaderGetConfigVars
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3declare( strict_types=1 );
4
5namespace MediaWiki\Extension\ConfirmEdit\Turnstile;
6
7use MediaWiki\Config\Config;
8use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
9
10class Hooks implements ResourceLoaderGetConfigVarsHook {
11    /**
12     * Adds extra variables to the global config
13     *
14     * @param array &$vars Global variables object
15     * @param string $skin
16     * @param Config $config
17     */
18    public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
19        if ( $config->get( 'CaptchaClass' ) === Turnstile::class ) {
20            $vars['wgConfirmEditConfig'] = [
21                'turnstileSiteKey' => $config->get( 'TurnstileSiteKey' ),
22                'turnstileScriptURL' => 'https://challenges.cloudflare.com/turnstile/v0/api.js'
23            ];
24        }
25    }
26}