MediaWiki  master
MediaWiki\ResourceLoader\MessageBlobStore Class Reference

This class generates message blobs for use by ResourceLoader. More...

Inheritance diagram for MediaWiki\ResourceLoader\MessageBlobStore:
Collaboration diagram for MediaWiki\ResourceLoader\MessageBlobStore:

Public Member Functions

 __construct (ResourceLoader $rl, ?LoggerInterface $logger, ?WANObjectCache $wanObjectCache)
 
 clear ()
 Invalidate cache keys for all known modules. More...
 
 getBlob (Module $module, $lang)
 Get the message blob for a module. More...
 
 getBlobs (array $modules, $lang)
 Get the message blobs for a set of modules. More...
 
 setLogger (LoggerInterface $logger)
 
 updateMessage ( $key)
 Invalidate cache keys for modules using this message key. More...
 

Static Public Member Functions

static clearGlobalCacheEntry (WANObjectCache $cache)
 Invalidate cache keys for all known modules. More...
 

Protected Member Functions

 fetchMessage ( $key, $lang)
 
 recacheMessageBlob ( $cacheKey, Module $module, $lang)
 

Protected Attributes

LoggerInterface $logger
 
WANObjectCache $wanCache
 

Detailed Description

This class generates message blobs for use by ResourceLoader.

A message blob is a JSON object containing the interface messages for a certain module in a certain language.

Since
1.17

Definition at line 51 of file MessageBlobStore.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\ResourceLoader\MessageBlobStore::__construct ( ResourceLoader  $rl,
?LoggerInterface  $logger,
?WANObjectCache  $wanObjectCache 
)
Parameters
ResourceLoader$rl
LoggerInterface | null$logger
WANObjectCache | null$wanObjectCache

Definition at line 66 of file MessageBlobStore.php.

References MediaWiki\ResourceLoader\MessageBlobStore\$logger, and MediaWiki\MediaWikiServices\getInstance().

Member Function Documentation

◆ clear()

MediaWiki\ResourceLoader\MessageBlobStore::clear ( )

Invalidate cache keys for all known modules.

Definition at line 191 of file MessageBlobStore.php.

◆ clearGlobalCacheEntry()

static MediaWiki\ResourceLoader\MessageBlobStore::clearGlobalCacheEntry ( WANObjectCache  $cache)
static

Invalidate cache keys for all known modules.

Called by LocalisationCache after cache is regenerated.

Parameters
WANObjectCache$cache

Definition at line 202 of file MessageBlobStore.php.

References $cache.

◆ fetchMessage()

MediaWiki\ResourceLoader\MessageBlobStore::fetchMessage (   $key,
  $lang 
)
protected
Since
1.27
Parameters
string$keyMessage key
string$langLanguage code
Returns
string|null

Definition at line 219 of file MessageBlobStore.php.

References $lang, and wfMessage().

◆ getBlob()

MediaWiki\ResourceLoader\MessageBlobStore::getBlob ( Module  $module,
  $lang 
)

Get the message blob for a module.

Since
1.27
Parameters
Module$module
string$langLanguage code
Returns
string JSON

Definition at line 97 of file MessageBlobStore.php.

References $lang, MediaWiki\ResourceLoader\MessageBlobStore\getBlobs(), and MediaWiki\ResourceLoader\Module\getName().

◆ getBlobs()

MediaWiki\ResourceLoader\MessageBlobStore::getBlobs ( array  $modules,
  $lang 
)

Get the message blobs for a set of modules.

Since
1.27
Parameters
Module[]$modulesArray of module objects keyed by name
string$langLanguage code
Returns
string[] An array mapping module names to message blobs

Definition at line 110 of file MessageBlobStore.php.

References $cache, $lang, $modules, MediaWiki\ResourceLoader\MessageBlobStore\$wanCache, and MediaWiki\ResourceLoader\MessageBlobStore\recacheMessageBlob().

Referenced by MediaWiki\ResourceLoader\MessageBlobStore\getBlob().

◆ recacheMessageBlob()

MediaWiki\ResourceLoader\MessageBlobStore::recacheMessageBlob (   $cacheKey,
Module  $module,
  $lang 
)
protected
Since
1.27
Parameters
string$cacheKey
Module$module
string$lang
Returns
string JSON blob

Definition at line 163 of file MessageBlobStore.php.

References $blob, $cache, $lang, MediaWiki\ResourceLoader\MessageBlobStore\$wanCache, DB_REPLICA, Wikimedia\Rdbms\Database\getCacheSetOptions(), and wfGetDB().

Referenced by MediaWiki\ResourceLoader\MessageBlobStore\getBlobs().

◆ setLogger()

MediaWiki\ResourceLoader\MessageBlobStore::setLogger ( LoggerInterface  $logger)
Since
1.27
Parameters
LoggerInterface$logger

Definition at line 85 of file MessageBlobStore.php.

References MediaWiki\ResourceLoader\MessageBlobStore\$logger.

◆ updateMessage()

MediaWiki\ResourceLoader\MessageBlobStore::updateMessage (   $key)

Invalidate cache keys for modules using this message key.

Called by MessageCache when a message has changed.

Parameters
string$keyMessage key

Definition at line 180 of file MessageBlobStore.php.

Member Data Documentation

◆ $logger

LoggerInterface MediaWiki\ResourceLoader\MessageBlobStore::$logger
protected

◆ $wanCache

WANObjectCache MediaWiki\ResourceLoader\MessageBlobStore::$wanCache
protected

The documentation for this class was generated from the following file: