Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3use MediaWiki\Extension\Gadgets\GadgetRepo;
4use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
5use MediaWiki\Extension\Gadgets\MediaWikiGadgetsJsonRepo;
6use MediaWiki\Extension\Gadgets\MultiGadgetRepo;
7use MediaWiki\MediaWikiServices;
8
9return [
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];