- $this->store = new $storeClass( $storeArg );
- foreach ( [ 'manualRecache', 'forceRecache' ] as $var ) {
- if ( isset( $conf[$var] ) ) {
- $this->$var = $conf[$var];
- }
- }
+ return new $storeClass( $storeArg );
+ }
+
+ /**
+ * @var array
+ * @since 1.34
+ */
+ public const CONSTRUCTOR_OPTIONS = [
+ // True to treat all files as expired until they are regenerated by this object.
+ 'forceRecache',
+ 'manualRecache',
+ 'ExtensionMessagesFiles',
+ 'MessagesDirs',
+ ];
+
+ /**
+ * For constructor parameters, see the documentation in DefaultSettings.php
+ * for $wgLocalisationCacheConf.
+ *
+ * Do not construct this directly. Use MediaWikiServices.
+ *
+ * @param ServiceOptions $options
+ * @param LCStore $store What backend to use for storage
+ * @param LoggerInterface $logger
+ * @param callable[] $clearStoreCallbacks To be called whenever the cache is cleared. Can be
+ * used to clear other caches that depend on this one, such as ResourceLoader's
+ * MessageBlobStore.
+ * @throws MWException
+ */
+ function __construct(
+ ServiceOptions $options,
+ LCStore $store,
+ LoggerInterface $logger,
+ array $clearStoreCallbacks = []
+ ) {
+ $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
+
+ $this->options = $options;
+ $this->store = $store;
+ $this->logger = $logger;
+ $this->clearStoreCallbacks = $clearStoreCallbacks;
+
+ // Keep this separate from $this->options so it can be mutable
+ $this->manualRecache = $options->get( 'manualRecache' );