Merge "Make LocalisationCache a service" into REL1_34
[lhc/web/wiklou.git] / includes / ServiceWiring.php
index dcb4aaf..60a5356 100644 (file)
@@ -287,6 +287,36 @@ return [
                );
        },
 
+       'LocalisationCache' => function ( MediaWikiServices $services ) : LocalisationCache {
+               $conf = $services->getMainConfig()->get( 'LocalisationCacheConf' );
+
+               $logger = LoggerFactory::getInstance( 'localisation' );
+
+               $store = LocalisationCache::getStoreFromConf(
+                       $conf, $services->getMainConfig()->get( 'CacheDirectory' ) );
+               $logger->debug( 'LocalisationCache: using store ' . get_class( $store ) );
+
+               return new $conf['class'](
+                       new ServiceOptions(
+                               LocalisationCache::$constructorOptions,
+                               // Two of the options are stored in $wgLocalisationCacheConf
+                               $conf,
+                               // In case someone set that config variable and didn't reset all keys, set defaults.
+                               [
+                                       'forceRecache' => false,
+                                       'manualRecache' => false,
+                               ],
+                               // Some other options come from config itself
+                               $services->getMainConfig()
+                       ),
+                       $store,
+                       $logger,
+                       [ function () use ( $services ) {
+                               $services->getResourceLoader()->getMessageBlobStore()->clear();
+                       } ]
+               );
+       },
+
        'LocalServerObjectCache' => function ( MediaWikiServices $services ) : BagOStuff {
                $config = $services->getMainConfig();
                $cacheId = ObjectCache::detectLocalServerCache();