Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | |
3 | use MediaWiki\Extension\Gadgets\GadgetRepo; |
4 | use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo; |
5 | use MediaWiki\Extension\Gadgets\MediaWikiGadgetsJsonRepo; |
6 | use MediaWiki\Extension\Gadgets\MultiGadgetRepo; |
7 | use MediaWiki\MediaWikiServices; |
8 | |
9 | return [ |
10 | 'GadgetsRepo' => static function ( MediaWikiServices $services ): GadgetRepo { |
11 | $wanCache = $services->getMainWANObjectCache(); |
12 | $revisionLookup = $services->getRevisionLookup(); |
13 | $dbProvider = $services->getConnectionProvider(); |
14 | switch ( $services->getMainConfig()->get( 'GadgetsRepo' ) ) { |
15 | case 'definition': |
16 | return new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup ); |
17 | case 'json': |
18 | return new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup ); |
19 | case 'json+definition': |
20 | return new MultiGadgetRepo( [ |
21 | new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup ), |
22 | new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup ) |
23 | ] ); |
24 | default: |
25 | throw new InvalidArgumentException( 'Unexpected value for $wgGadgetsRepo' ); |
26 | } |
27 | }, |
28 | ]; |