Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 37 |
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\Extension\WikiLambda\AbstractContent\AbstractWikiRequest; |
| 14 | use MediaWiki\Extension\WikiLambda\Authorization\ZObjectAuthorization; |
| 15 | use MediaWiki\Extension\WikiLambda\AWStorage\AWArticleStore; |
| 16 | use MediaWiki\Extension\WikiLambda\AWStorage\DBAWArticleStore; |
| 17 | use MediaWiki\Extension\WikiLambda\Cache\MemcachedWrapper; |
| 18 | use MediaWiki\Extension\WikiLambda\ParserFunction\WikifunctionsPFragmentRenderer; |
| 19 | use MediaWiki\Logger\LoggerFactory; |
| 20 | use MediaWiki\MediaWikiServices; |
| 21 | |
| 22 | /** |
| 23 | * @codeCoverageIgnore |
| 24 | */ |
| 25 | return [ |
| 26 | // For repo wikis |
| 27 | |
| 28 | 'WikiLambdaZObjectStore' => static function ( MediaWikiServices $services ): ZObjectStore { |
| 29 | return WikiLambdaServices::buildZObjectStore( $services ); |
| 30 | }, |
| 31 | |
| 32 | 'WikiLambdaZObjectAuthorization' => static function ( MediaWikiServices $services ): ZObjectAuthorization { |
| 33 | return new ZObjectAuthorization( |
| 34 | LoggerFactory::getInstance( 'WikiLambda' ) |
| 35 | ); |
| 36 | }, |
| 37 | |
| 38 | // For both repo and client wikis |
| 39 | |
| 40 | 'WikiLambdaMemcachedWrapper' => static function ( MediaWikiServices $services ): MemcachedWrapper { |
| 41 | return WikiLambdaServices::buildMemcachedWrapper( $services ); |
| 42 | }, |
| 43 | |
| 44 | 'WikiLambdaPFragmentRenderer' => static function ( MediaWikiServices $services ): WikifunctionsPFragmentRenderer { |
| 45 | return new WikifunctionsPFragmentRenderer( |
| 46 | LoggerFactory::getInstance( 'WikiLambda' ), |
| 47 | $services->getUserFactory(), |
| 48 | $services->getMainConfig() |
| 49 | ); |
| 50 | }, |
| 51 | |
| 52 | // For client wikis |
| 53 | |
| 54 | 'WikifunctionsClientStore' => static function ( MediaWikiServices $services ): WikifunctionsClientStore { |
| 55 | return new WikifunctionsClientStore( |
| 56 | $services->getConnectionProvider() |
| 57 | ); |
| 58 | }, |
| 59 | |
| 60 | // For abstract mode |
| 61 | |
| 62 | 'AbstractWikiRequest' => static function ( MediaWikiServices $services ): AbstractWikiRequest { |
| 63 | return new AbstractWikiRequest( |
| 64 | $services->getMainConfig(), |
| 65 | $services->getHttpRequestFactory(), |
| 66 | $services->get( 'WikiLambdaPFragmentRenderer' ) |
| 67 | ); |
| 68 | }, |
| 69 | |
| 70 | // For abstract and abstract client mode |
| 71 | |
| 72 | 'AbstractWikiArticleStore' => static function ( MediaWikiServices $services ): AWArticleStore { |
| 73 | // TODO: in the future, we could configure this and build additional implementations if |
| 74 | // we wanted to have alternative storage backends in different environments. If the final |
| 75 | // infrastracture is MariaDB we won't need to do this, we can depend on RDBMS to be an |
| 76 | // available backend, so we would only need to handle configuration for virtual host. |
| 77 | return new DBAWArticleStore( |
| 78 | $services->getConnectionProvider() |
| 79 | ); |
| 80 | } |
| 81 | ]; |