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\Config\ConfigException; |
4 | use MediaWiki\Extension\ApiFeatureUsage\ApiFeatureUsageQueryEngine; |
5 | use MediaWiki\Extension\ApiFeatureUsage\ApiFeatureUsageQueryEngineSql; |
6 | use MediaWiki\MediaWikiServices; |
7 | |
8 | return [ |
9 | 'ApiFeatureUsage.QueryEngine' => static function ( MediaWikiServices $services ): ApiFeatureUsageQueryEngine { |
10 | $conf = $services->getMainConfig()->get( 'ApiFeatureUsageQueryEngineConf' ); |
11 | |
12 | if ( isset( $conf['factory'] ) ) { |
13 | $spec = [ 'factory' => $conf['factory'], 'args' => [ $conf ] ]; |
14 | } elseif ( isset( $conf['class'] ) ) { |
15 | $class = $conf['class']; |
16 | $spec = [ 'class' => $class, 'args' => [ $conf ] ]; |
17 | if ( is_a( $class, ApiFeatureUsageQueryEngineSql::class, true ) ) { |
18 | $spec['services'] = [ |
19 | 'ConnectionProvider', |
20 | 'WRStatsFactory', |
21 | 'ObjectCacheFactory' |
22 | ]; |
23 | } |
24 | } else { |
25 | throw new ConfigException( '$wgApiFeatureUsageQueryEngineConf does not define an engine' ); |
26 | } |
27 | |
28 | /** @var ApiFeatureUsageQueryEngine $instance */ |
29 | // @phan-suppress-next-line PhanTypeInvalidCallableArraySize |
30 | $instance = $services->getObjectFactory()->createObject( $spec ); |
31 | |
32 | return $instance; |
33 | }, |
34 | ]; |