Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
CommunityConfigurationHooks
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 2
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 onCommunityConfigurationProvider_initList
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3/**
4 * WikiLambda CommunityConfiguration integration hooks.
5 *
6 * Kept as a separate class (rather than extending ClientHooks) so the
7 * CommunityConfigurationProvider_initListHook interface is only autoloaded
8 * when the CommunityConfiguration extension is present. This preserves
9 * CommunityConfiguration as a soft dependency.
10 *
11 * @file
12 * @ingroup Extensions
13 * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt
14 * @license MIT
15 */
16
17namespace MediaWiki\Extension\WikiLambda\HookHandler;
18
19use MediaWiki\Config\Config;
20use MediaWiki\Extension\CommunityConfiguration\Hooks\CommunityConfigurationProvider_initListHook;
21
22class CommunityConfigurationHooks implements CommunityConfigurationProvider_initListHook {
23
24    public function __construct(
25        private readonly Config $config
26    ) {
27    }
28
29    /**
30     * Hide each of our CC providers on wikis where its feature mode is off,
31     * so the Special:CommunityConfiguration dashboard only shows providers
32     * whose data is actually consumed on this wiki.
33     *
34     * @param array &$providers
35     * @return void
36     */
37    public function onCommunityConfigurationProvider_initList( array &$providers ): void {
38        if ( !$this->config->get( 'WikiLambdaEnableClientMode' ) ) {
39            unset( $providers['WikifunctionsSuggestions'] );
40        }
41        if ( !$this->config->get( 'WikiLambdaEnableAbstractMode' ) ) {
42            unset( $providers['AbstractWikiSuggestedWikifunctions'] );
43        }
44        if ( !$this->config->get( 'WikiLambdaEnableAbstractClientMode' ) ) {
45            unset( $providers['AbstractWikiOptedInArticles'] );
46        }
47    }
48}