Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
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        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];