1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Services; |
4
|
|
|
|
5
|
|
|
use Onoi\BlobStore\BlobStore; |
6
|
|
|
use Onoi\CallbackContainer\CallbackContainer; |
7
|
|
|
use Onoi\CallbackContainer\ContainerBuilder; |
8
|
|
|
use SMW\Factbox\FactboxFactory; |
9
|
|
|
use SMW\MediaWiki\Jobs\JobFactory; |
10
|
|
|
use SMW\MediaWiki\MediaWikiNsContentReader; |
11
|
|
|
use SMW\MediaWiki\ManualEntryLogger; |
12
|
|
|
use SMW\MediaWiki\Database; |
13
|
|
|
use SMW\MediaWiki\PageCreator; |
14
|
|
|
use SMW\MediaWiki\PageUpdater; |
15
|
|
|
use SMW\MediaWiki\TitleCreator; |
16
|
|
|
use SMW\MediaWiki\JobQueueLookup; |
17
|
|
|
use SMW\Query\QuerySourceFactory; |
18
|
|
|
use SMW\SQLStore\ChangeOp\TempChangeOpStore; |
19
|
|
|
use SMW\Query\Result\CachedQueryResultPrefetcher; |
20
|
|
|
use SMW\Utils\BufferedStatsdCollector; |
21
|
|
|
use SMW\Parser\LinksProcessor; |
22
|
|
|
use SMW\Protection\EditProtectionValidator; |
23
|
|
|
use SMW\Protection\EditProtectionUpdater; |
24
|
|
|
use SMW\Services\DataValueServiceFactory; |
25
|
|
|
use SMW\Settings; |
26
|
|
|
use SMW\StoreFactory; |
27
|
|
|
use SMW\MessageFormatter; |
28
|
|
|
use SMW\NamespaceExaminer; |
29
|
|
|
use SMW\ParserData; |
30
|
|
|
use SMW\ContentParser; |
31
|
|
|
use SMW\DeferredCallableUpdate; |
32
|
|
|
use SMW\InMemoryPoolCache; |
33
|
|
|
use SMW\PropertyAnnotatorFactory; |
34
|
|
|
use SMW\CacheFactory; |
35
|
|
|
use SMW\IteratorFactory; |
36
|
|
|
use SMW\QueryFactory; |
37
|
|
|
use SMW\DataItemFactory; |
38
|
|
|
use SMW\PropertySpecificationLookup; |
39
|
|
|
use SMW\PropertyHierarchyLookup; |
40
|
|
|
use SMW\PropertyLabelFinder; |
41
|
|
|
use SMW\CachedPropertyValuesPrefetcher; |
42
|
|
|
use SMW\Localizer; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @license GNU GPL v2+ |
46
|
|
|
* @since 2.3 |
47
|
|
|
* |
48
|
|
|
* @author mwjames |
49
|
|
|
*/ |
50
|
|
|
class SharedServicesContainer implements CallbackContainer { |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @see CallbackContainer::register |
54
|
|
|
* |
55
|
|
|
* @since 2.3 |
56
|
|
|
*/ |
57
|
|
|
public function register( ContainerBuilder $containerBuilder ) { |
58
|
|
|
$this->registerCallbackHandlers( $containerBuilder ); |
59
|
|
|
$this->registerCallbackHandlersByFactory( $containerBuilder ); |
60
|
|
|
$this->registerCallbackHandlersByConstructedInstance( $containerBuilder ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
private function registerCallbackHandlers( $containerBuilder ) { |
64
|
|
|
|
65
|
|
|
$containerBuilder->registerCallback( 'Settings', function( $containerBuilder ) { |
66
|
|
|
$containerBuilder->registerExpectedReturnType( 'Settings', '\SMW\Settings' ); |
67
|
|
|
return Settings::newFromGlobals(); |
68
|
|
|
} ); |
69
|
|
|
|
70
|
|
|
$containerBuilder->registerCallback( 'Store', function( $containerBuilder, $storeClass = null ) { |
71
|
|
|
$containerBuilder->registerExpectedReturnType( 'Store', '\SMW\Store' ); |
72
|
|
|
|
73
|
|
|
$settings = $containerBuilder->singleton( 'Settings' ); |
74
|
|
|
$storeClass = $storeClass !== null ? $storeClass : $settings->get( 'smwgDefaultStore' ); |
75
|
|
|
|
76
|
|
|
$store = StoreFactory::getStore( $storeClass ); |
77
|
|
|
|
78
|
|
|
$options = $store->getOptions(); |
79
|
|
|
$options->set( 'smwgDefaultStore', $settings->get( 'smwgDefaultStore' ) ); |
80
|
|
|
$options->set( 'smwgSemanticsEnabled', $settings->get( 'smwgSemanticsEnabled' ) ); |
81
|
|
|
$options->set( 'smwgAutoRefreshSubject', $settings->get( 'smwgAutoRefreshSubject' ) ); |
82
|
|
|
$options->set( 'smwgEnableUpdateJobs', $settings->get( 'smwgEnableUpdateJobs' ) ); |
83
|
|
|
|
84
|
|
|
return $store; |
85
|
|
|
} ); |
86
|
|
|
|
87
|
|
|
$containerBuilder->registerCallback( 'Cache', function( $containerBuilder, $cacheType = null ) { |
88
|
|
|
$containerBuilder->registerExpectedReturnType( 'Cache', '\Onoi\Cache\Cache' ); |
89
|
|
|
return $containerBuilder->create( 'CacheFactory' )->newMediaWikiCompositeCache( $cacheType ); |
90
|
|
|
} ); |
91
|
|
|
|
92
|
|
|
$containerBuilder->registerCallback( 'NamespaceExaminer', function() use ( $containerBuilder ) { |
93
|
|
|
return NamespaceExaminer::newFromArray( $containerBuilder->singleton( 'Settings' )->get( 'smwgNamespacesWithSemanticLinks' ) ); |
94
|
|
|
} ); |
95
|
|
|
|
96
|
|
|
$containerBuilder->registerCallback( 'ParserData', function( $containerBuilder, \Title $title, \ParserOutput $parserOutput ) { |
97
|
|
|
$containerBuilder->registerExpectedReturnType( 'ParserData', '\SMW\ParserData' ); |
98
|
|
|
return new ParserData( $title, $parserOutput ); |
99
|
|
|
} ); |
100
|
|
|
|
101
|
|
|
$containerBuilder->registerCallback( 'LinksProcessor', function( $containerBuilder ) { |
102
|
|
|
$containerBuilder->registerExpectedReturnType( 'LinksProcessor', '\SMW\Parser\LinksProcessor' ); |
103
|
|
|
return new LinksProcessor(); |
104
|
|
|
} ); |
105
|
|
|
|
106
|
|
|
$containerBuilder->registerCallback( 'MessageFormatter', function( $containerBuilder, \Language $language ) { |
107
|
|
|
$containerBuilder->registerExpectedReturnType( 'MessageFormatter', '\SMW\MessageFormatter' ); |
108
|
|
|
return new MessageFormatter( $language ); |
109
|
|
|
} ); |
110
|
|
|
|
111
|
|
|
$containerBuilder->registerCallback( 'MediaWikiNsContentReader', function() use ( $containerBuilder ) { |
112
|
|
|
$containerBuilder->registerExpectedReturnType( 'MediaWikiNsContentReader', '\SMW\MediaWiki\MediaWikiNsContentReader' ); |
113
|
|
|
return new MediaWikiNsContentReader(); |
114
|
|
|
} ); |
115
|
|
|
|
116
|
|
|
$containerBuilder->registerCallback( 'PageCreator', function( $containerBuilder ) { |
117
|
|
|
$containerBuilder->registerExpectedReturnType( 'PageCreator', '\SMW\MediaWiki\PageCreator' ); |
118
|
|
|
return new PageCreator(); |
119
|
|
|
} ); |
120
|
|
|
|
121
|
|
|
$containerBuilder->registerCallback( 'PageUpdater', function( $containerBuilder, Database $connection = null ) { |
122
|
|
|
$containerBuilder->registerExpectedReturnType( 'PageUpdater', '\SMW\MediaWiki\PageUpdater' ); |
123
|
|
|
return new PageUpdater( $connection ); |
124
|
|
|
} ); |
125
|
|
|
|
126
|
|
|
$containerBuilder->registerCallback( 'JobQueueLookup', function( $containerBuilder, Database $connection ) { |
127
|
|
|
$containerBuilder->registerExpectedReturnType( 'JobQueueLookup', '\SMW\MediaWiki\JobQueueLookup' ); |
128
|
|
|
return new JobQueueLookup( $connection ); |
129
|
|
|
} ); |
130
|
|
|
|
131
|
|
|
$containerBuilder->registerCallback( 'ManualEntryLogger', function( $containerBuilder ) { |
132
|
|
|
$containerBuilder->registerExpectedReturnType( 'ManualEntryLogger', '\SMW\MediaWiki\ManualEntryLogger' ); |
133
|
|
|
return new ManualEntryLogger(); |
134
|
|
|
} ); |
135
|
|
|
|
136
|
|
|
$containerBuilder->registerCallback( 'TitleCreator', function( $containerBuilder ) { |
137
|
|
|
$containerBuilder->registerExpectedReturnType( 'TitleCreator', '\SMW\MediaWiki\TitleCreator' ); |
138
|
|
|
return new TitleCreator(); |
139
|
|
|
} ); |
140
|
|
|
|
141
|
|
|
$containerBuilder->registerCallback( 'ContentParser', function( $containerBuilder, \Title $title ) { |
142
|
|
|
$containerBuilder->registerExpectedReturnType( 'ContentParser', '\SMW\ContentParser' ); |
143
|
|
|
return new ContentParser( $title ); |
144
|
|
|
} ); |
145
|
|
|
|
146
|
|
|
$containerBuilder->registerCallback( 'DeferredCallableUpdate', function( $containerBuilder, \Closure $callback, Database $connection = null ) { |
147
|
|
|
$containerBuilder->registerExpectedReturnType( 'DeferredCallableUpdate', '\SMW\DeferredCallableUpdate' ); |
148
|
|
|
return new DeferredCallableUpdate( $callback, $connection ); |
149
|
|
|
} ); |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @var InMemoryPoolCache |
153
|
|
|
*/ |
154
|
|
|
$containerBuilder->registerCallback( 'InMemoryPoolCache', function( $containerBuilder ) { |
155
|
|
|
$containerBuilder->registerExpectedReturnType( 'InMemoryPoolCache', '\SMW\InMemoryPoolCache' ); |
156
|
|
|
return InMemoryPoolCache::getInstance(); |
157
|
|
|
} ); |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @var PropertyAnnotatorFactory |
161
|
|
|
*/ |
162
|
|
|
$containerBuilder->registerCallback( 'PropertyAnnotatorFactory', function( $containerBuilder ) { |
163
|
|
|
$containerBuilder->registerExpectedReturnType( 'PropertyAnnotatorFactory', '\SMW\PropertyAnnotatorFactory' ); |
164
|
|
|
return new PropertyAnnotatorFactory(); |
165
|
|
|
} ); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
private function registerCallbackHandlersByFactory( $containerBuilder ) { |
169
|
|
|
|
170
|
|
|
/** |
171
|
|
|
* @var CacheFactory |
172
|
|
|
*/ |
173
|
|
|
$containerBuilder->registerCallback( 'CacheFactory', function( $containerBuilder, $mainCacheType = null ) { |
174
|
|
|
$containerBuilder->registerExpectedReturnType( 'CacheFactory', '\SMW\CacheFactory' ); |
175
|
|
|
return new CacheFactory( $mainCacheType ); |
176
|
|
|
} ); |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* @var IteratorFactory |
180
|
|
|
*/ |
181
|
|
|
$containerBuilder->registerCallback( 'IteratorFactory', function( $containerBuilder ) { |
182
|
|
|
$containerBuilder->registerExpectedReturnType( 'IteratorFactory', '\SMW\IteratorFactory' ); |
183
|
|
|
return new IteratorFactory(); |
184
|
|
|
} ); |
185
|
|
|
|
186
|
|
|
/** |
187
|
|
|
* @var JobFactory |
188
|
|
|
*/ |
189
|
|
|
$containerBuilder->registerCallback( 'JobFactory', function( $containerBuilder ) { |
190
|
|
|
$containerBuilder->registerExpectedReturnType( 'JobFactory', '\SMW\MediaWiki\Jobs\JobFactory' ); |
191
|
|
|
return new JobFactory(); |
192
|
|
|
} ); |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @var FactboxFactory |
196
|
|
|
*/ |
197
|
|
|
$containerBuilder->registerCallback( 'FactboxFactory', function( $containerBuilder ) { |
198
|
|
|
$containerBuilder->registerExpectedReturnType( 'FactboxFactory', '\SMW\Factbox\FactboxFactory' ); |
199
|
|
|
return new FactboxFactory(); |
200
|
|
|
} ); |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @var QuerySourceFactory |
204
|
|
|
*/ |
205
|
|
|
$containerBuilder->registerCallback( 'QuerySourceFactory', function( $containerBuilder ) { |
206
|
|
|
$containerBuilder->registerExpectedReturnType( 'QuerySourceFactory', '\SMW\Query\QuerySourceFactory' ); |
207
|
|
|
|
208
|
|
|
return new QuerySourceFactory( |
209
|
|
|
$containerBuilder->create( 'Store' ), |
210
|
|
|
$containerBuilder->create( 'Settings' )->get( 'smwgQuerySources' ), |
211
|
|
|
$containerBuilder->create( 'Settings' )->get( 'smwgSparqlQueryEndpoint' ) |
212
|
|
|
); |
213
|
|
|
} ); |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* @var QueryFactory |
217
|
|
|
*/ |
218
|
|
|
$containerBuilder->registerCallback( 'QueryFactory', function( $containerBuilder ) { |
219
|
|
|
$containerBuilder->registerExpectedReturnType( 'QueryFactory', '\SMW\QueryFactory' ); |
220
|
|
|
return new QueryFactory(); |
221
|
|
|
} ); |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* @var DataItemFactory |
225
|
|
|
*/ |
226
|
|
|
$containerBuilder->registerCallback( 'DataItemFactory', function( $containerBuilder ) { |
227
|
|
|
$containerBuilder->registerExpectedReturnType( 'DataItemFactory', '\SMW\DataItemFactory' ); |
228
|
|
|
return new DataItemFactory(); |
229
|
|
|
} ); |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* @var DataValueServiceFactory |
233
|
|
|
*/ |
234
|
|
|
$containerBuilder->registerCallback( 'DataValueServiceFactory', function( $containerBuilder ) { |
235
|
|
|
$containerBuilder->registerExpectedReturnType( 'DataValueServiceFactory', '\SMW\Services\DataValueServiceFactory' ); |
236
|
|
|
|
237
|
|
|
$containerBuilder->registerFromFile( |
238
|
|
|
$containerBuilder->singleton( 'Settings' )->get( 'smwgServicesFileDir' ) . '/' . DataValueServiceFactory::SERVICE_FILE |
239
|
|
|
); |
240
|
|
|
|
241
|
|
|
$dataValueServiceFactory = new DataValueServiceFactory( |
242
|
|
|
$containerBuilder |
243
|
|
|
); |
244
|
|
|
|
245
|
|
|
return $dataValueServiceFactory; |
246
|
|
|
} ); |
247
|
|
|
} |
248
|
|
|
|
249
|
|
|
private function registerCallbackHandlersByConstructedInstance( $containerBuilder ) { |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* @var BlobStore |
253
|
|
|
*/ |
254
|
|
|
$containerBuilder->registerCallback( 'BlobStore', function( $containerBuilder, $namespace, $cacheType = null, $ttl = 0 ) { |
255
|
|
|
$containerBuilder->registerExpectedReturnType( 'BlobStore', '\Onoi\BlobStore\BlobStore' ); |
256
|
|
|
|
257
|
|
|
$cacheFactory = $containerBuilder->create( 'CacheFactory' ); |
258
|
|
|
|
259
|
|
|
$blobStore = new BlobStore( |
260
|
|
|
$namespace, |
261
|
|
|
$cacheFactory->newMediaWikiCompositeCache( $cacheType ) |
262
|
|
|
); |
263
|
|
|
|
264
|
|
|
$blobStore->setNamespacePrefix( |
265
|
|
|
$cacheFactory->getCachePrefix() |
266
|
|
|
); |
267
|
|
|
|
268
|
|
|
$blobStore->setExpiryInSeconds( |
269
|
|
|
$ttl |
270
|
|
|
); |
271
|
|
|
|
272
|
|
|
$blobStore->setUsageState( |
273
|
|
|
$cacheType !== CACHE_NONE && $cacheType !== false |
274
|
|
|
); |
275
|
|
|
|
276
|
|
|
return $blobStore; |
277
|
|
|
} ); |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @var CachedQueryResultPrefetcher |
281
|
|
|
*/ |
282
|
|
|
$containerBuilder->registerCallback( 'CachedQueryResultPrefetcher', function( $containerBuilder, $cacheType = null ) { |
283
|
|
|
$containerBuilder->registerExpectedReturnType( 'CachedQueryResultPrefetcher', '\SMW\Query\Result\CachedQueryResultPrefetcher' ); |
284
|
|
|
|
285
|
|
|
$settings = $containerBuilder->singleton( 'Settings' ); |
286
|
|
|
$cacheType = $cacheType === null ? $settings->get( 'smwgQueryResultCacheType' ) : $cacheType; |
287
|
|
|
|
288
|
|
|
$cachedQueryResultPrefetcher = new CachedQueryResultPrefetcher( |
289
|
|
|
$containerBuilder->create( 'Store' ), |
290
|
|
|
$containerBuilder->singleton( 'QueryFactory' ), |
291
|
|
|
$containerBuilder->create( |
292
|
|
|
'BlobStore', |
293
|
|
|
CachedQueryResultPrefetcher::CACHE_NAMESPACE, |
294
|
|
|
$cacheType, |
295
|
|
|
$settings->get( 'smwgQueryResultCacheLifetime' ) |
296
|
|
|
), |
297
|
|
|
$containerBuilder->singleton( |
298
|
|
|
'BufferedStatsdCollector', |
299
|
|
|
CachedQueryResultPrefetcher::STATSD_ID |
300
|
|
|
) |
301
|
|
|
); |
302
|
|
|
|
303
|
|
|
$cachedQueryResultPrefetcher->setHashModifier( |
304
|
|
|
$settings->get( 'smwgFulltextSearchIndexableDataTypes' ) |
305
|
|
|
); |
306
|
|
|
|
307
|
|
|
$cachedQueryResultPrefetcher->setLogger( |
308
|
|
|
$containerBuilder->singleton( 'MediaWikiLogger' ) |
309
|
|
|
); |
310
|
|
|
|
311
|
|
|
$cachedQueryResultPrefetcher->setNonEmbeddedCacheLifetime( |
312
|
|
|
$settings->get( 'smwgQueryResultNonEmbeddedCacheLifetime' ) |
313
|
|
|
); |
314
|
|
|
|
315
|
|
|
return $cachedQueryResultPrefetcher; |
316
|
|
|
} ); |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @var CachedPropertyValuesPrefetcher |
320
|
|
|
*/ |
321
|
|
|
$containerBuilder->registerCallback( 'CachedPropertyValuesPrefetcher', function( $containerBuilder, $cacheType = null, $ttl = 604800 ) { |
322
|
|
|
$containerBuilder->registerExpectedReturnType( 'CachedPropertyValuesPrefetcher', CachedPropertyValuesPrefetcher::class ); |
323
|
|
|
|
324
|
|
|
$cachedPropertyValuesPrefetcher = new CachedPropertyValuesPrefetcher( |
325
|
|
|
$containerBuilder->create( 'Store' ), |
326
|
|
|
$containerBuilder->create( 'BlobStore', CachedPropertyValuesPrefetcher::CACHE_NAMESPACE, $cacheType, $ttl ) |
327
|
|
|
); |
328
|
|
|
|
329
|
|
|
return $cachedPropertyValuesPrefetcher; |
330
|
|
|
} ); |
331
|
|
|
|
332
|
|
|
/** |
333
|
|
|
* @var BufferedStatsdCollector |
334
|
|
|
*/ |
335
|
|
|
$containerBuilder->registerCallback( 'BufferedStatsdCollector', function( $containerBuilder, $id ) { |
336
|
|
|
$containerBuilder->registerExpectedReturnType( 'BufferedStatsdCollector', '\SMW\Utils\BufferedStatsdCollector' ); |
337
|
|
|
|
338
|
|
|
// Explicitly use the DB to access a SqlBagOstuff instance |
339
|
|
|
$cacheType = CACHE_DB; |
340
|
|
|
$ttl = 0; |
341
|
|
|
|
342
|
|
|
$bufferedStatsdCollector = new BufferedStatsdCollector( |
343
|
|
|
$containerBuilder->create( 'BlobStore', BufferedStatsdCollector::CACHE_NAMESPACE, $cacheType, $ttl ), |
344
|
|
|
$id |
345
|
|
|
); |
346
|
|
|
|
347
|
|
|
return $bufferedStatsdCollector; |
348
|
|
|
} ); |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @var PropertySpecificationLookup |
352
|
|
|
*/ |
353
|
|
|
$containerBuilder->registerCallback( 'PropertySpecificationLookup', function( $containerBuilder ) { |
354
|
|
|
$containerBuilder->registerExpectedReturnType( 'PropertySpecificationLookup', '\SMW\PropertySpecificationLookup' ); |
355
|
|
|
|
356
|
|
|
$propertySpecificationLookup = new PropertySpecificationLookup( |
357
|
|
|
$containerBuilder->singleton( 'CachedPropertyValuesPrefetcher' ), |
358
|
|
|
$containerBuilder->singleton( 'InMemoryPoolCache' )->getPoolCacheById( PropertySpecificationLookup::POOLCACHE_ID ) |
359
|
|
|
); |
360
|
|
|
|
361
|
|
|
return $propertySpecificationLookup; |
362
|
|
|
} ); |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* @var EditProtectionValidator |
366
|
|
|
*/ |
367
|
|
|
$containerBuilder->registerCallback( 'EditProtectionValidator', function( $containerBuilder ) { |
368
|
|
|
$containerBuilder->registerExpectedReturnType( 'EditProtectionValidator', '\SMW\Protection\EditProtectionValidator' ); |
369
|
|
|
|
370
|
|
|
$editProtectionValidator = new EditProtectionValidator( |
371
|
|
|
$containerBuilder->singleton( 'CachedPropertyValuesPrefetcher' ), |
372
|
|
|
$containerBuilder->singleton( 'InMemoryPoolCache' )->getPoolCacheById( EditProtectionValidator::POOLCACHE_ID ) |
373
|
|
|
); |
374
|
|
|
|
375
|
|
|
$editProtectionValidator->setEditProtectionRight( |
376
|
|
|
$containerBuilder->singleton( 'Settings' )->get( 'smwgEditProtectionRight' ) |
377
|
|
|
); |
378
|
|
|
|
379
|
|
|
return $editProtectionValidator; |
380
|
|
|
} ); |
381
|
|
|
|
382
|
|
|
/** |
383
|
|
|
* @var EditProtectionUpdater |
384
|
|
|
*/ |
385
|
|
|
$containerBuilder->registerCallback( 'EditProtectionUpdater', function( $containerBuilder, \WikiPage $wikiPage, \User $user = null ) { |
386
|
|
|
$containerBuilder->registerExpectedReturnType( 'EditProtectionUpdater', '\SMW\Protection\EditProtectionUpdater' ); |
387
|
|
|
|
388
|
|
|
$editProtectionUpdater = new EditProtectionUpdater( |
389
|
|
|
$wikiPage, |
390
|
|
|
$user |
391
|
|
|
); |
392
|
|
|
|
393
|
|
|
$editProtectionUpdater->setEditProtectionRight( |
394
|
|
|
$containerBuilder->singleton( 'Settings' )->get( 'smwgEditProtectionRight' ) |
395
|
|
|
); |
396
|
|
|
|
397
|
|
|
$editProtectionUpdater->setLogger( |
398
|
|
|
$containerBuilder->singleton( 'MediaWikiLogger' ) |
399
|
|
|
); |
400
|
|
|
|
401
|
|
|
return $editProtectionUpdater; |
402
|
|
|
} ); |
403
|
|
|
|
404
|
|
|
/** |
405
|
|
|
* @var PropertyHierarchyLookup |
406
|
|
|
*/ |
407
|
|
|
$containerBuilder->registerCallback( 'PropertyHierarchyLookup', function( $containerBuilder ) { |
408
|
|
|
$containerBuilder->registerExpectedReturnType( 'PropertyHierarchyLookup', '\SMW\PropertyHierarchyLookup' ); |
409
|
|
|
|
410
|
|
|
$propertyHierarchyLookup = new PropertyHierarchyLookup( |
411
|
|
|
$containerBuilder->create( 'Store' ), |
412
|
|
|
$containerBuilder->singleton( 'InMemoryPoolCache' )->getPoolCacheById( PropertyHierarchyLookup::POOLCACHE_ID ) |
413
|
|
|
); |
414
|
|
|
|
415
|
|
|
$propertyHierarchyLookup->setLogger( |
416
|
|
|
$containerBuilder->singleton( 'MediaWikiLogger' ) |
417
|
|
|
); |
418
|
|
|
|
419
|
|
|
$propertyHierarchyLookup->setSubcategoryDepth( |
420
|
|
|
$containerBuilder->create( 'Settings' )->get( 'smwgQSubcategoryDepth' ) |
421
|
|
|
); |
422
|
|
|
|
423
|
|
|
$propertyHierarchyLookup->setSubpropertyDepth( |
424
|
|
|
$containerBuilder->create( 'Settings' )->get( 'smwgQSubpropertyDepth' ) |
425
|
|
|
); |
426
|
|
|
|
427
|
|
|
return $propertyHierarchyLookup; |
428
|
|
|
} ); |
429
|
|
|
|
430
|
|
|
/** |
431
|
|
|
* @var PropertyLabelFinder |
432
|
|
|
*/ |
433
|
|
|
$containerBuilder->registerCallback( 'PropertyLabelFinder', function( $containerBuilder ) { |
434
|
|
|
$containerBuilder->registerExpectedReturnType( 'PropertyLabelFinder', '\SMW\PropertyLabelFinder' ); |
435
|
|
|
|
436
|
|
|
$extraneousLanguage = Localizer::getInstance()->getExtraneousLanguage(); |
437
|
|
|
|
438
|
|
|
$propertyLabelFinder = new PropertyLabelFinder( |
439
|
|
|
$containerBuilder->create( 'Store' ), |
440
|
|
|
$extraneousLanguage->getPropertyLabels(), |
441
|
|
|
$extraneousLanguage->getCanonicalPropertyLabels(), |
442
|
|
|
$extraneousLanguage->getCanonicalDatatypeLabels() |
443
|
|
|
); |
444
|
|
|
|
445
|
|
|
return $propertyLabelFinder; |
446
|
|
|
} ); |
447
|
|
|
|
448
|
|
|
/** |
449
|
|
|
* @var TempChangeOpStore |
450
|
|
|
*/ |
451
|
|
|
$containerBuilder->registerCallback( 'TempChangeOpStore', function( $containerBuilder ) { |
452
|
|
|
$containerBuilder->registerExpectedReturnType( 'TempChangeOpStore', '\SMW\SQLStore\ChangeOp\TempChangeOpStore' ); |
453
|
|
|
|
454
|
|
|
$cacheFactory = $containerBuilder->create( 'CacheFactory' ); |
455
|
|
|
$cacheType = null; |
456
|
|
|
|
457
|
|
|
$tempChangeOpStore = new TempChangeOpStore( |
458
|
|
|
$cacheFactory->newMediaWikiCompositeCache( $cacheType ), |
459
|
|
|
$cacheFactory->getCachePrefix() |
460
|
|
|
); |
461
|
|
|
|
462
|
|
|
$tempChangeOpStore->setLogger( |
463
|
|
|
$containerBuilder->singleton( 'MediaWikiLogger' ) |
464
|
|
|
); |
465
|
|
|
|
466
|
|
|
return $tempChangeOpStore; |
467
|
|
|
} ); |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
} |
471
|
|
|
|