Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 30 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * WikiLambda Service Wiring |
4 | * |
5 | * @file |
6 | * @ingroup Extensions |
7 | * @copyright 2020– Abstract Wikipedia team; see AUTHORS.txt |
8 | * @license MIT |
9 | */ |
10 | |
11 | namespace MediaWiki\Extension\WikiLambda; |
12 | |
13 | use MediaWiki\Config\ConfigException; |
14 | use MediaWiki\Extension\WikiLambda\Authorization\ZObjectAuthorization; |
15 | use MediaWiki\Logger\LoggerFactory; |
16 | use MediaWiki\MainConfigNames; |
17 | use MediaWiki\MediaWikiServices; |
18 | use Wikimedia\ObjectCache\BagOStuff; |
19 | |
20 | /** |
21 | * @codeCoverageIgnore |
22 | */ |
23 | return [ |
24 | 'WikiLambdaZObjectStore' => static function ( MediaWikiServices $services ): ZObjectStore { |
25 | return new ZObjectStore( |
26 | $services->getDBLoadBalancerFactory(), |
27 | $services->getTitleFactory(), |
28 | $services->getWikiPageFactory(), |
29 | $services->getRevisionStore(), |
30 | $services->getUserGroupManager(), |
31 | LoggerFactory::getInstance( 'WikiLambda' ) |
32 | ); |
33 | }, |
34 | |
35 | 'WikiLambdaZObjectAuthorization' => static function ( MediaWikiServices $services ): ZObjectAuthorization { |
36 | return new ZObjectAuthorization( |
37 | LoggerFactory::getInstance( 'WikiLambda' ) |
38 | ); |
39 | }, |
40 | |
41 | 'WikiLambdaZObjectStash' => static function ( MediaWikiServices $services ): BagOStuff { |
42 | $extensionConfig = $services->getConfigFactory()->makeConfig( 'WikiLambda' ); |
43 | $requestedCache = $extensionConfig->get( 'WikiLambdaObjectCache' ); |
44 | |
45 | if ( !$requestedCache ) { |
46 | // Just short-cut to the existing Stash in this case |
47 | return $services->getMainObjectStash(); |
48 | } |
49 | |
50 | $mainConfig = $services->getMainConfig(); |
51 | $cacheParameters = $mainConfig->get( MainConfigNames::ObjectCaches )[$requestedCache] ?? null; |
52 | if ( !$cacheParameters ) { |
53 | throw new ConfigException( |
54 | "\$wgObjectCaches must have \"$requestedCache\" set (via WikiLambdaObjectCache)" |
55 | ); |
56 | } |
57 | |
58 | return $services->getObjectCacheFactory()->newFromParams( $cacheParameters ); |
59 | }, |
60 | ]; |