Translate extension for MediaWiki
 
Loading...
Searching...
No Matches
ServiceWiring.php
Go to the documentation of this file.
1<?php
10use MediaWiki\Config\ServiceOptions;
35use MediaWiki\Logger\LoggerFactory;
36use MediaWiki\MediaWikiServices;
37
39return [
40 'Translate:ConfigHelper' => static function (): ConfigHelper {
41 return new ConfigHelper();
42 },
43
44 'Translate:CsvTranslationImporter' => static function ( MediaWikiServices $services ): CsvTranslationImporter {
45 return new CsvTranslationImporter( $services->getWikiPageFactory() );
46 },
47
48 'Translate:EntitySearch' => static function ( MediaWikiServices $services ): EntitySearch {
50 $services->getMainWANObjectCache(),
51 $services->getCollationFactory()->makeCollation( 'uca-default-u-kn' ),
52 MessageGroups::singleton(),
53 $services->getNamespaceInfo(),
54 $services->get( 'Translate:MessageIndex' ),
55 $services->getTitleParser(),
56 $services->getTitleFormatter()
57 );
58 },
59
60 'Translate:ExternalMessageSourceStateImporter' => static function (
61 MediaWikiServices $services
64 $services->getMainConfig(),
65 $services->get( 'Translate:GroupSynchronizationCache' ),
66 $services->getJobQueueGroup(),
67 LoggerFactory::getInstance( 'Translate.GroupSynchronization' ),
68 MessageIndex::singleton()
69 );
70 },
71
72 'Translate:GroupSynchronizationCache' => static function (
73 MediaWikiServices $services
75 return new GroupSynchronizationCache( $services->get( 'Translate:PersistentCache' ) );
76 },
77
78 'Translate:MessageBundleStore' => static function ( MediaWikiServices $services ): MessageBundleStore {
80 new RevTagStore(),
81 $services->getJobQueueGroup(),
82 $services->getLanguageNameUtils(),
83 $services->get( 'Translate:MessageIndex' )
84 );
85 },
86
87 'Translate:MessageGroupReview' => static function ( MediaWikiServices $services ): MessageGroupReview {
89 $services->getDBLoadBalancer(),
90 $services->getHookContainer()
91 );
92 },
93
94 'Translate:MessageIndex' => static function ( MediaWikiServices $services ): MessageIndex {
95 $params = $services->getMainConfig()->get( 'TranslateMessageIndex' );
96 if ( is_string( $params ) ) {
97 $params = (array)$params;
98 }
99
100 $class = array_shift( $params );
101 // @phan-suppress-next-line PhanTypeExpectedObjectOrClassName
102 return new $class( $params );
103 },
104
105 'Translate:ParsingPlaceholderFactory' => static function (): ParsingPlaceholderFactory {
107 },
108
109 'Translate:PersistentCache' => static function ( MediaWikiServices $services ): PersistentCache {
111 $services->getDBLoadBalancer(),
112 $services->getJsonCodec()
113 );
114 },
115
116 'Translate:ProgressStatsTableFactory' => static function ( MediaWikiServices $services ): ProgressStatsTableFactory
117 {
118 return new ProgressStatsTableFactory(
119 $services->getLinkRenderer(),
120 $services->get( 'Translate:ConfigHelper' )
121 );
122 },
123
124 'Translate:SubpageListBuilder' => static function ( MediaWikiServices $services ): SubpageListBuilder
125 {
126 return new SubpageListBuilder(
127 $services->get( 'Translate:TranslatableBundleFactory' ),
128 $services->getLinkBatchFactory()
129 );
130 },
131
132 'Translate:TranslatableBundleFactory' => static function ( MediaWikiServices $services ): TranslatableBundleFactory
133 {
134 return new TranslatableBundleFactory(
135 $services->get( 'Translate:TranslatablePageStore' ),
136 $services->get( 'Translate:MessageBundleStore' )
137 );
138 },
139
140 'Translate:TranslatableBundleMover' => static function ( MediaWikiServices $services ): TranslatableBundleMover
141 {
142 return new TranslatableBundleMover(
143 $services->getMovePageFactory(),
144 $services->getJobQueueGroup(),
145 $services->getLinkBatchFactory(),
146 $services->get( 'Translate:TranslatableBundleFactory' ),
147 $services->get( 'Translate:SubpageListBuilder' ),
148 $services->getMainConfig()->get( 'TranslatePageMoveLimit' )
149 );
150 },
151
152 'Translate:TranslatablePageParser' => static function ( MediaWikiServices $services ): TranslatablePageParser
153 {
154 return new TranslatablePageParser(
155 $services->get( 'Translate:ParsingPlaceholderFactory' )
156 );
157 },
158
159 'Translate:TranslatablePageStore' => static function ( MediaWikiServices $services ): TranslatablePageStore
160 {
161 return new TranslatablePageStore(
162 $services->get( 'Translate:MessageIndex' ),
163 $services->getJobQueueGroup(),
164 new RevTagStore(),
165 $services->getDBLoadBalancer()
166 );
167 },
168
169 'Translate:TranslationStashReader' => static function ( MediaWikiServices $services ): TranslationStashReader
170 {
171 $db = $services->getDBLoadBalancer()->getConnectionRef( DB_REPLICA );
172 return new TranslationStashStorage( $db );
173 },
174
175 'Translate:TranslationStatsDataProvider' => static function (
176 MediaWikiServices $services
179 new ServiceOptions(
180 TranslationStatsDataProvider::CONSTRUCTOR_OPTIONS,
181 $services->getMainConfig()
182 ),
183 $services->getObjectFactory()
184 );
185 },
186
187 'Translate:TranslationUnitStoreFactory' => static function (
188 MediaWikiServices $services
190 return new TranslationUnitStoreFactory( $services->getDBLoadBalancer() );
191 },
192
193 'Translate:TranslatorActivity' => static function ( MediaWikiServices $services ): TranslatorActivity {
194 $query = new TranslatorActivityQuery(
195 $services->getMainConfig(),
196 $services->getDBLoadBalancer()
197 );
198
199 return new TranslatorActivity(
200 $services->getMainObjectStash(),
201 $query,
202 $services->getJobQueueGroup()
203 );
204 },
205
206 'Translate:TtmServerFactory' => static function ( MediaWikiServices $services ): TtmServerFactory {
207 $config = $services->getMainConfig();
208
209 $default = $config->get( 'TranslateTranslationDefaultService' );
210 if ( $default === false ) {
211 $default = null;
212 }
213
214 return new TtmServerFactory( $config->get( 'TranslateTranslationServices' ), $default );
215 }
216];
return[ 'Translate:ConfigHelper'=> static function():ConfigHelper { return new ConfigHelper();}, 'Translate:CsvTranslationImporter'=> static function(MediaWikiServices $services):CsvTranslationImporter { return new CsvTranslationImporter( $services->getWikiPageFactory());}, 'Translate:EntitySearch'=> static function(MediaWikiServices $services):EntitySearch { return new EntitySearch($services->getMainWANObjectCache(), $services->getCollationFactory() ->makeCollation( 'uca-default-u-kn'), MessageGroups::singleton(), $services->getNamespaceInfo(), $services->get( 'Translate:MessageIndex'), $services->getTitleParser(), $services->getTitleFormatter());}, 'Translate:ExternalMessageSourceStateImporter'=> static function(MediaWikiServices $services):ExternalMessageSourceStateImporter { return new ExternalMessageSourceStateImporter($services->getMainConfig(), $services->get( 'Translate:GroupSynchronizationCache'), $services->getJobQueueGroup(), LoggerFactory::getInstance( 'Translate.GroupSynchronization'), MessageIndex::singleton());}, 'Translate:GroupSynchronizationCache'=> static function(MediaWikiServices $services):GroupSynchronizationCache { return new GroupSynchronizationCache( $services->get( 'Translate:PersistentCache'));}, 'Translate:MessageBundleStore'=> static function(MediaWikiServices $services):MessageBundleStore { return new MessageBundleStore(new RevTagStore(), $services->getJobQueueGroup(), $services->getLanguageNameUtils(), $services->get( 'Translate:MessageIndex'));}, 'Translate:MessageGroupReview'=> static function(MediaWikiServices $services):MessageGroupReview { return new MessageGroupReview($services->getDBLoadBalancer(), $services->getHookContainer());}, 'Translate:MessageIndex'=> static function(MediaWikiServices $services):MessageIndex { $params=$services->getMainConfig() ->get( 'TranslateMessageIndex');if(is_string( $params)) { $params=(array) $params;} $class=array_shift( $params);return new $class( $params);}, 'Translate:ParsingPlaceholderFactory'=> static function():ParsingPlaceholderFactory { return new ParsingPlaceholderFactory();}, 'Translate:PersistentCache'=> static function(MediaWikiServices $services):PersistentCache { return new PersistentDatabaseCache($services->getDBLoadBalancer(), $services->getJsonCodec());}, 'Translate:ProgressStatsTableFactory'=> static function(MediaWikiServices $services):ProgressStatsTableFactory { return new ProgressStatsTableFactory($services->getLinkRenderer(), $services->get( 'Translate:ConfigHelper'));}, 'Translate:SubpageListBuilder'=> static function(MediaWikiServices $services):SubpageListBuilder { return new SubpageListBuilder($services->get( 'Translate:TranslatableBundleFactory'), $services->getLinkBatchFactory());}, 'Translate:TranslatableBundleFactory'=> static function(MediaWikiServices $services):TranslatableBundleFactory { return new TranslatableBundleFactory($services->get( 'Translate:TranslatablePageStore'), $services->get( 'Translate:MessageBundleStore'));}, 'Translate:TranslatableBundleMover'=> static function(MediaWikiServices $services):TranslatableBundleMover { return new TranslatableBundleMover($services->getMovePageFactory(), $services->getJobQueueGroup(), $services->getLinkBatchFactory(), $services->get( 'Translate:TranslatableBundleFactory'), $services->get( 'Translate:SubpageListBuilder'), $services->getMainConfig() ->get( 'TranslatePageMoveLimit'));}, 'Translate:TranslatablePageParser'=> static function(MediaWikiServices $services):TranslatablePageParser { return new TranslatablePageParser($services->get( 'Translate:ParsingPlaceholderFactory'));}, 'Translate:TranslatablePageStore'=> static function(MediaWikiServices $services):TranslatablePageStore { return new TranslatablePageStore($services->get( 'Translate:MessageIndex'), $services->getJobQueueGroup(), new RevTagStore(), $services->getDBLoadBalancer());}, 'Translate:TranslationStashReader'=> static function(MediaWikiServices $services):TranslationStashReader { $db=$services->getDBLoadBalancer() ->getConnectionRef(DB_REPLICA);return new TranslationStashStorage( $db);}, 'Translate:TranslationStatsDataProvider'=> static function(MediaWikiServices $services):TranslationStatsDataProvider { return new TranslationStatsDataProvider(new ServiceOptions(TranslationStatsDataProvider::CONSTRUCTOR_OPTIONS, $services->getMainConfig()), $services->getObjectFactory());}, 'Translate:TranslationUnitStoreFactory'=> static function(MediaWikiServices $services):TranslationUnitStoreFactory { return new TranslationUnitStoreFactory( $services->getDBLoadBalancer());}, 'Translate:TranslatorActivity'=> static function(MediaWikiServices $services):TranslatorActivity { $query=new TranslatorActivityQuery($services->getMainConfig(), $services->getDBLoadBalancer());return new TranslatorActivity($services->getMainObjectStash(), $query, $services->getJobQueueGroup());}, 'Translate:TtmServerFactory'=> static function(MediaWikiServices $services):TtmServerFactory { $config=$services->getMainConfig();$default=$config->get( 'TranslateTranslationDefaultService');if( $default===false) { $default=null;} return new TtmServerFactory( $config->get( 'TranslateTranslationServices'), $default);}]
@phpcs-require-sorted-array
A persistent cache implementation using the database.
Provides methods to get and change the state of a message group.
Class to manage revision tags for translatable bundles.
Generates list of subpages for the translatable bundle that can be moved or deleted.
Create instances of various classes based on the type of TranslatableBundle.
Contains the core logic to validate and move translatable bundles.
Generates ParserOutput from text or removes all tags from a text.
Service for searching message groups and message keys.
A helper class added to work with configuration values of the Translate Extension.
Create unique placeholders that can be used when parsing (wiki)text.
Factory class for accessing message groups individually by id or all of them as an list.
Creates a database of keys in all groups, so that namespace and key can be used to get the groups the...
Defines what method should be provided by a class implementing a persistent cache.