Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
Hooks | |
0.00% |
0 / 15 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
onParserFirstCallInit | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
onBeforePageDisplay | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
onResourceLoaderGetConfigVars | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\FundraiserLandingPage; |
4 | |
5 | use MediaWiki\Extension\FundraiserLandingPage\Specials\FundraiserLandingPage; |
6 | use MediaWiki\Output\OutputPage; |
7 | use MediaWiki\Parser\Parser; |
8 | use Skin; |
9 | |
10 | class Hooks { |
11 | /** |
12 | * Register the parser function hooks 'switchlanguage' and 'switchcountry' |
13 | * with the MW backend. |
14 | * |
15 | * @param Parser $parser The MW parser object to hook into. |
16 | * |
17 | * @return bool Always true |
18 | */ |
19 | public static function onParserFirstCallInit( $parser ) { |
20 | $parser->setFunctionHook( |
21 | 'switchlanguage', |
22 | [ FundraiserLandingPage::class, 'fundraiserLandingPageSwitchLanguage' ] |
23 | ); |
24 | $parser->setFunctionHook( |
25 | 'switchcountry', |
26 | [ FundraiserLandingPage::class, 'fundraiserLandingPageSwitchCountry' ] |
27 | ); |
28 | |
29 | // Return true so that MediaWiki continues to load extensions. |
30 | return true; |
31 | } |
32 | |
33 | /** |
34 | * BeforePageDisplay hook handler |
35 | * |
36 | * @param OutputPage $out |
37 | * @param Skin $skin |
38 | * @return bool |
39 | */ |
40 | public static function onBeforePageDisplay( $out, $skin ) { |
41 | // TODO Restrict logging to anonymous article viewing once it's demonstrated |
42 | // that data from EventLogging is the same as that received from Kafkatee. |
43 | $out->addModules( 'ext.fundraiserLandingPage.LogPageview' ); |
44 | return true; |
45 | } |
46 | |
47 | /** |
48 | * ResourceLoaderGetConfigVars hook handler |
49 | * Send php config vars to js via ResourceLoader |
50 | * |
51 | * @param array &$vars variables to be added to the output of the startup module |
52 | * @return bool |
53 | */ |
54 | public static function onResourceLoaderGetConfigVars( &$vars ) { |
55 | global $wgFundraiserLandingPageELSampleRate; |
56 | |
57 | $vars[ 'wgFundraiserLandingPageELSampleRate' ] = |
58 | $wgFundraiserLandingPageELSampleRate; |
59 | |
60 | return true; |
61 | } |
62 | } |