Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
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 | $srvCache = $services->getObjectCacheFactory()->getLocalServerInstance( CACHE_HASH ); |
15 | switch ( $services->getMainConfig()->get( 'GadgetsRepo' ) ) { |
16 | case 'definition': |
17 | return new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup, $srvCache ); |
18 | case 'json': |
19 | return new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup ); |
20 | case 'json+definition': |
21 | return new MultiGadgetRepo( [ |
22 | new MediaWikiGadgetsJsonRepo( $dbProvider, $wanCache, $revisionLookup ), |
23 | new MediaWikiGadgetsDefinitionRepo( $dbProvider, $wanCache, $revisionLookup, $srvCache ) |
24 | ] ); |
25 | default: |
26 | throw new InvalidArgumentException( 'Unexpected value for $wgGadgetsRepo' ); |
27 | } |
28 | }, |
29 | ]; |