mediawiki-extensions-Gadgets/includes/ServiceWiring.php
Siddharth VP 34a1a297c2 Make repo configuration independent of ObjectFactory specs
Replace $wgGadgetsRepoClass with $wgGadgetsRepo.

Change-Id: I3dc1e29d1c3c65a18c206e7aa50e5bf31a55cc21
2023-12-12 13:15:31 +00:00

22 lines
762 B
PHP

<?php
use MediaWiki\Extension\Gadgets\GadgetDefinitionNamespaceRepo;
use MediaWiki\Extension\Gadgets\GadgetRepo;
use MediaWiki\Extension\Gadgets\MediaWikiGadgetsDefinitionRepo;
use MediaWiki\MediaWikiServices;
return [
'GadgetsRepo' => static function ( MediaWikiServices $services ): GadgetRepo {
$wanCache = $services->getMainWANObjectCache();
$revisionLookup = $services->getRevisionLookup();
switch ( $services->getMainConfig()->get( 'GadgetsRepo' ) ) {
case 'definition':
return new MediaWikiGadgetsDefinitionRepo( $wanCache, $revisionLookup );
case 'json':
return new GadgetDefinitionNamespaceRepo( $wanCache, $revisionLookup );
default:
throw new InvalidArgumentException( 'Unexpected value for $wgGadgetsRepo' );
}
},
];