Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 71
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3use Flow\Data\FlowObjectCache;
4use Flow\Data\Storage\PostRevisionStorage;
5use Flow\Data\Storage\PostRevisionTopicHistoryStorage;
6use Flow\DbFactory;
7use Flow\FlowActions;
8use Flow\Notifications\Controller as NotificationsController;
9use Flow\Repository\TreeRepository;
10use Flow\RevisionActionPermissions;
11use Flow\TemplateHelper;
12use MediaWiki\Config\ServiceOptions;
13use MediaWiki\Logger\LoggerFactory;
14use MediaWiki\MediaWikiServices;
15use MediaWiki\User\User;
16use Psr\Log\LoggerInterface;
17
18/**
19 * Service wiring for Flow services
20 *
21 * Currently most services are defined in and retrieved
22 * from the flow container, but they should be moved
23 * here, see T170330.
24 *
25 * PHPUnit doesn't understand code coverage for code outside of classes/functions,
26 * like service wiring files.
27 * @codeCoverageIgnore
28 *
29 * @author DannyS712
30 *
31 * @phpcs-require-sorted-array
32 */
33return [
34    'FlowActions' => static function ( MediaWikiServices $services ): FlowActions {
35        // Flow configuration
36        return new FlowActions(
37            require __DIR__ . '/../FlowActions.php'
38        );
39    },
40
41    'FlowCache' => static function ( MediaWikiServices $services ): FlowObjectCache {
42        // New storage implementation
43        return new FlowObjectCache(
44            $services->getMainWANObjectCache(),
45            $services->getService( 'FlowDbFactory' ),
46            $services->getMainConfig()->get( 'FlowCacheTime' )
47        );
48    },
49
50    'FlowDbFactory' => static function ( MediaWikiServices $services ): DbFactory {
51        // Always returns the correct database for flow storage
52        $config = $services->getMainConfig();
53        return new DbFactory(
54            $config->get( 'FlowDefaultWikiDb' ),
55            $config->get( 'FlowCluster' )
56        );
57    },
58
59    'FlowDefaultLogger' => static function ( MediaWikiServices $services ): LoggerInterface {
60        return LoggerFactory::getInstance( 'Flow' );
61    },
62
63    'FlowNotificationsController' => static function (
64        MediaWikiServices $services
65    ): NotificationsController {
66        return new NotificationsController(
67            new ServiceOptions( NotificationsController::CONSTRUCTOR_OPTIONS, $services->getMainConfig() ),
68            $services->getContentLanguage(),
69            $services->getService( 'FlowTreeRepository' )
70        );
71    },
72
73    'FlowPermissions' => static function ( MediaWikiServices $services ): RevisionActionPermissions {
74        return new RevisionActionPermissions(
75            $services->getService( 'FlowActions' ),
76            $services->getService( 'FlowUser' )
77        );
78    },
79
80    'FlowPostRevisionStorage' => static function ( MediaWikiServices $services ): PostRevisionStorage {
81        return new PostRevisionStorage(
82            $services->getService( 'FlowDbFactory' ),
83            $services->getMainConfig()->get( 'FlowExternalStore' ),
84            $services->getService( 'FlowTreeRepository' )
85        );
86    },
87
88    'FlowPostRevisionTopicHistoryStorage' => static function (
89        MediaWikiServices $services
90    ): PostRevisionTopicHistoryStorage {
91        return new PostRevisionTopicHistoryStorage(
92            $services->getService( 'FlowPostRevisionStorage' ),
93            $services->getService( 'FlowTreeRepository' )
94        );
95    },
96
97    'FlowTemplateHandler' => static function ( MediaWikiServices $services ): TemplateHelper {
98        return new TemplateHelper(
99            __DIR__ . '/../handlebars',
100            $services->getMainConfig()->get( 'FlowServerCompileTemplates' )
101        );
102    },
103
104    'FlowTreeRepository' => static function ( MediaWikiServices $services ): TreeRepository {
105        // Database Access Layer external from main implementation
106        return new TreeRepository(
107            $services->getService( 'FlowDbFactory' ),
108            $services->getService( 'FlowCache' )
109        );
110    },
111
112    'FlowUser' => static function ( MediaWikiServices $services ): User {
113        if ( defined( 'RUN_MAINTENANCE_IF_MAIN' ) ) {
114            return new User;
115        } else {
116            return RequestContext::getMain()->getUser();
117        }
118    },
119];