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 / 2
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 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 onEditPage__showEditForm_initial
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onResourceLoaderGetConfigVars
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * @file
4 */
5
6// phpcs:disable MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName
7
8namespace MediaWiki\Extension\TemplateWizard;
9
10use ExtensionRegistry;
11use MediaWiki\Config\Config;
12use MediaWiki\EditPage\EditPage;
13use MediaWiki\Hook\EditPage__showEditForm_initialHook;
14use MediaWiki\Output\OutputPage;
15use MediaWiki\ResourceLoader\Hook\ResourceLoaderGetConfigVarsHook;
16
17/**
18 * Hooks for the TemplateWizard extension.
19 */
20class Hooks implements
21    EditPage__showEditForm_initialHook,
22    ResourceLoaderGetConfigVarsHook
23{
24
25    /**
26     * Add the extension's module.
27     * @link https://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:initial
28     * @param EditPage $editPage The current EditPage object.
29     * @param OutputPage $output The OutputPage object.
30     */
31    public function onEditPage__showEditForm_initial(
32        $editPage,
33        $output
34    ) {
35        $output->addModules( 'ext.TemplateWizard' );
36    }
37
38    /**
39     * Adds extra variables to the global config
40     *
41     * @param array &$vars Global variables object
42     * @param string $skin
43     * @param Config $config
44     */
45    public function onResourceLoaderGetConfigVars( array &$vars, $skin, Config $config ): void {
46        $extensionRegistry = ExtensionRegistry::getInstance();
47
48        $vars['wgTemplateWizardConfig'] = [
49            'cirrusSearchLookup' => $extensionRegistry->isLoaded( 'CirrusSearch' ),
50        ];
51    }
52}