Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
SpecialPageInitListHandler
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 onSpecialPage_initList
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2namespace MediaWiki\IPInfo\HookHandler;
3
4use MediaWiki\IPInfo\Special\SpecialIPInfo;
5use MediaWiki\SpecialPage\Hook\SpecialPage_initListHook;
6use MediaWiki\User\TempUser\TempUserConfig;
7
8/**
9 * Conditionally register Special:IPInfo if temporary users are known on the local wiki.
10 */
11class SpecialPageInitListHandler implements SpecialPage_initListHook {
12
13    private TempUserConfig $tempUserConfig;
14
15    public function __construct( TempUserConfig $tempUserConfig ) {
16        $this->tempUserConfig = $tempUserConfig;
17    }
18
19    /**
20     * Conditionally register Special:IPInfo if temporary users are known on the local wiki.
21     *
22     * @param array &$list Associative array of special page descriptors keyed by special page name, passed
23     * by reference.
24     * @return void
25     */
26    public function onSpecialPage_initList( &$list ): void {
27        if ( $this->tempUserConfig->isKnown() ) {
28            $list['IPInfo'] = [
29                'class' => SpecialIPInfo::class,
30                'services' => [
31                    'UserOptionsManager',
32                    'UserNameUtils',
33                    'LocalServerObjectCache',
34                    'IPInfoTempUserIPLookup',
35                    'UserIdentityLookup',
36                    'IPInfoInfoManager',
37                    'PermissionManager',
38                    'MainConfig'
39                ]
40            ];
41        }
42    }
43}