Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ResourceLoaderHooks
0.00% covered (danger)
0.00%
0 / 24
0.00% covered (danger)
0.00%
0 / 2
20
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
 onResourceLoaderRegisterModules
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3declare( strict_types = 1 );
4
5namespace Wikibase\MediaInfo;
6
7use MediaWiki\Registration\ExtensionRegistry;
8use MediaWiki\ResourceLoader\Hook\ResourceLoaderRegisterModulesHook;
9use MediaWiki\ResourceLoader\ResourceLoader;
10
11/**
12 * @license GPL-2.0-or-later
13 */
14class ResourceLoaderHooks implements ResourceLoaderRegisterModulesHook {
15
16    public function __construct(
17        private readonly ExtensionRegistry $extensionRegistry,
18    ) {
19    }
20
21    public function onResourceLoaderRegisterModules( ResourceLoader $rl ): void {
22        $extensionJson = json_decode(
23            file_get_contents( __DIR__ . '/../extension.json' ),
24            associative: true
25        );
26        '@phan-var array $extensionJson';
27        $modules = json_decode(
28            file_get_contents( __DIR__ . '/../extraResourceModulesProcessedByHookHandler.json' ),
29            associative: true
30        );
31        '@phan-var array $modules';
32        foreach ( $modules as &$module ) {
33            $module['localBasePath'] ??= __DIR__ . '/../' . $extensionJson['ResourceFileModulePaths']['localBasePath'];
34            $module['remoteExtPath'] ??= $extensionJson['ResourceFileModulePaths']['remoteExtPath'];
35        }
36
37        if ( $this->extensionRegistry->isLoaded( 'WikibaseQualityConstraints' ) ) {
38            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-issues-short';
39            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-issues-long';
40            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-potentialissues-short';
41            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-potentialissues-long';
42            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-suggestions-short';
43            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-suggestions-long';
44            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-parameterissues-short';
45            $modules['wikibase.mediainfo.statements']['messages'][] = 'wbqc-parameterissues-long';
46        }
47
48        $rl->register( $modules );
49    }
50
51}