MediaWiki  1.28.0
MessageBlobStore Class Reference

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

Inheritance diagram for MessageBlobStore:
Collaboration diagram for MessageBlobStore:

Public Member Functions

 __construct (ResourceLoader $rl=null, LoggerInterface $logger=null)
 
 clear ()
 Invalidate cache keys for all known modules. More...
 
 get (ResourceLoader $resourceLoader, $modules, $lang)
 
 getBlob (ResourceLoaderModule $module, $lang)
 Get the message blob for a module. More...
 
 getBlobs (array $modules, $lang)
 Get the message blobs for a set of modules. More...
 
 insertMessageBlob ($name, ResourceLoaderModule $module, $lang)
 
 setLogger (LoggerInterface $logger)
 
 updateMessage ($key)
 Invalidate cache keys for modules using this message key. More...
 

Protected Member Functions

 fetchMessage ($key, $lang)
 
 getResourceLoader ()
 
 recacheMessageBlob ($cacheKey, ResourceLoaderModule $module, $lang)
 

Protected Attributes

LoggerInterface $logger
 
WANObjectCache $wanCache
 

Private Member Functions

 generateMessageBlob (ResourceLoaderModule $module, $lang)
 Generate the message blob for a given module in a given language. More...
 
 makeCacheKey (ResourceLoaderModule $module, $lang)
 

Private Attributes

 $resourceloader
 

Detailed Description

This class generates message blobs for use by ResourceLoader modules.

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

Definition at line 36 of file MessageBlobStore.php.

Constructor & Destructor Documentation

MessageBlobStore::__construct ( ResourceLoader  $rl = null,
LoggerInterface  $logger = null 
)
Parameters
ResourceLoader$rl
LoggerInterface$logger

Definition at line 55 of file MessageBlobStore.php.

References ObjectCache\getMainWANInstance().

Member Function Documentation

MessageBlobStore::clear ( )

Invalidate cache keys for all known modules.

Called by LocalisationCache after cache is regenerated.

Definition at line 191 of file MessageBlobStore.php.

References $cache, and $wanCache.

MessageBlobStore::fetchMessage (   $key,
  $lang 
)
protected
Since
1.27
Parameters
string$keyMessage key
string$langLanguage code
Returns
string

Definition at line 218 of file MessageBlobStore.php.

References $lang, $value, and wfMessage().

Referenced by generateMessageBlob().

MessageBlobStore::generateMessageBlob ( ResourceLoaderModule  $module,
  $lang 
)
private

Generate the message blob for a given module in a given language.

Parameters
ResourceLoaderModule$module
string$langLanguage code
Returns
string JSON blob

Definition at line 237 of file MessageBlobStore.php.

References $lang, $messages, as, FormatJson\encode(), fetchMessage(), ResourceLoaderModule\getMessages(), and ResourceLoaderModule\getName().

Referenced by recacheMessageBlob().

MessageBlobStore::get ( ResourceLoader  $resourceLoader,
  $modules,
  $lang 
)
Deprecated:
since 1.27 Use getBlobs() instead
Returns
array

Definition at line 129 of file MessageBlobStore.php.

References $lang, and getBlobs().

Referenced by ResourceLoader\register().

MessageBlobStore::getBlob ( ResourceLoaderModule  $module,
  $lang 
)

Get the message blob for a module.

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

Definition at line 77 of file MessageBlobStore.php.

References $lang, getBlobs(), and ResourceLoaderModule\getName().

MessageBlobStore::getBlobs ( array  $modules,
  $lang 
)

Get the message blobs for a set of modules.

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

Definition at line 90 of file MessageBlobStore.php.

References $cache, $lang, $name, $wanCache, as, makeCacheKey(), and recacheMessageBlob().

Referenced by get(), and getBlob().

MessageBlobStore::getResourceLoader ( )
protected
Since
1.27
Returns
ResourceLoader

Definition at line 202 of file MessageBlobStore.php.

References $resourceloader.

Referenced by updateMessage().

MessageBlobStore::insertMessageBlob (   $name,
ResourceLoaderModule  $module,
  $lang 
)
Deprecated:
since 1.27 Obsolete. Used to populate a cache table in the database.
Returns
bool

Definition at line 137 of file MessageBlobStore.php.

MessageBlobStore::makeCacheKey ( ResourceLoaderModule  $module,
  $lang 
)
private
Since
1.27
Parameters
ResourceLoaderModule$module
string$lang
Returns
string Cache key

Definition at line 147 of file MessageBlobStore.php.

References $lang, $messages, ResourceLoaderModule\getMessages(), and ResourceLoaderModule\getName().

Referenced by getBlobs().

MessageBlobStore::recacheMessageBlob (   $cacheKey,
ResourceLoaderModule  $module,
  $lang 
)
protected
Since
1.27
Parameters
string$cacheKey
ResourceLoaderModule$module
string$lang
Returns
string JSON blob

Definition at line 162 of file MessageBlobStore.php.

References $blob, $cache, $lang, $wanCache, DB_REPLICA, generateMessageBlob(), Database\getCacheSetOptions(), and wfGetDB().

Referenced by getBlobs().

MessageBlobStore::setLogger ( LoggerInterface  $logger)
Since
1.27
Parameters
LoggerInterface$logger

Definition at line 65 of file MessageBlobStore.php.

References $logger.

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 179 of file MessageBlobStore.php.

References as, and getResourceLoader().

Member Data Documentation

LoggerInterface MessageBlobStore::$logger
protected

Definition at line 44 of file MessageBlobStore.php.

Referenced by setLogger().

MessageBlobStore::$resourceloader
private

Definition at line 39 of file MessageBlobStore.php.

Referenced by getResourceLoader().

WANObjectCache MessageBlobStore::$wanCache
protected

Definition at line 49 of file MessageBlobStore.php.

Referenced by clear(), getBlobs(), and recacheMessageBlob().


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