MediaWiki REL1_31
ResourceLoaderContext Class Reference

Object passed around to modules which contains information about the state of a specific loader request. More...

Inheritance diagram for ResourceLoaderContext:
Collaboration diagram for ResourceLoaderContext:

Public Member Functions

 __construct (ResourceLoader $resourceLoader, WebRequest $request)
 
 getDebug ()
 
 getDirection ()
 
 getFormat ()
 
 getHash ()
 All factors that uniquely identify this request, except 'modules'.
 
 getImage ()
 
 getImageObj ()
 If this is a request for an image, get the ResourceLoaderImage object.
 
 getLanguage ()
 
 getLogger ()
 
 getModules ()
 
 getOnly ()
 
 getRaw ()
 
 getRequest ()
 
 getResourceLoader ()
 
 getSkin ()
 
 getUser ()
 
 getUserObj ()
 Get the possibly-cached User object for the specified username.
 
 getVariant ()
 
 getVersion ()
 
 msg ( $key)
 Get a Message object with context set.
 
 shouldIncludeMessages ()
 
 shouldIncludeScripts ()
 
 shouldIncludeStyles ()
 

Static Public Member Functions

static expandModuleNames ( $modules)
 Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to an array of module names like ‘[ 'jquery.foo’, 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ]`.
 
static newDummyContext ()
 Return a dummy ResourceLoaderContext object suitable for passing into things that don't "really" need a context.
 

Protected Attributes

 $debug
 
 $direction
 
 $format
 
 $hash
 
 $image
 
 $imageObj
 
 $language
 
 $logger
 
 $modules
 
 $only
 
 $raw
 
 $request
 
 $resourceLoader
 
 $skin
 
 $user
 
 $userObj
 
 $variant
 
 $version
 

Detailed Description

Object passed around to modules which contains information about the state of a specific loader request.

Definition at line 32 of file ResourceLoaderContext.php.

Constructor & Destructor Documentation

◆ __construct()

ResourceLoaderContext::__construct ( ResourceLoader $resourceLoader,
WebRequest $request )
Parameters
ResourceLoader$resourceLoader
WebRequest$request

Definition at line 61 of file ResourceLoaderContext.php.

References $modules, $request, $resourceLoader, WebRequest\getRawVal(), skin(), and version.

Member Function Documentation

◆ expandModuleNames()

static ResourceLoaderContext::expandModuleNames ( $modules)
static

Expand a string of the form jquery.foo,bar|jquery.ui.baz,quux to an array of module names like ‘[ 'jquery.foo’, 'jquery.bar', 'jquery.ui.baz', 'jquery.ui.quux' ]`.

This process is reversed by ResourceLoader::makePackedModulesString().

Parameters
string$modulesPacked module name list
Returns
array Array of module names

Definition at line 106 of file ResourceLoaderContext.php.

References $modules, and $retval.

◆ getDebug()

ResourceLoaderContext::getDebug ( )
Returns
bool

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 261 of file ResourceLoaderContext.php.

References $debug.

Referenced by getHash().

◆ getDirection()

ResourceLoaderContext::getDirection ( )
Returns
string

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 194 of file ResourceLoaderContext.php.

References getLanguage(), and getRequest().

◆ getFormat()

ResourceLoaderContext::getFormat ( )
Returns
string|null

Definition at line 305 of file ResourceLoaderContext.php.

Referenced by getHash().

◆ getHash()

ResourceLoaderContext::getHash ( )

All factors that uniquely identify this request, except 'modules'.

The list of modules is excluded here for legacy reasons as most callers already split up handling of individual modules. Including it here would massively fragment the cache and decrease its usefulness.

E.g. Used by RequestFileCache to form a cache key for storing the reponse output.

Returns
string

Definition at line 376 of file ResourceLoaderContext.php.

References getDebug(), getFormat(), getImage(), getLanguage(), getOnly(), getRaw(), getSkin(), getUser(), getVariant(), and getVersion().

◆ getImage()

ResourceLoaderContext::getImage ( )
Returns
string|null

Definition at line 291 of file ResourceLoaderContext.php.

References $image.

Referenced by getHash().

◆ getImageObj()

ResourceLoaderContext::getImageObj ( )

If this is a request for an image, get the ResourceLoaderImage object.

Since
1.25
Returns
ResourceLoaderImage|bool false if a valid object cannot be created

Definition at line 315 of file ResourceLoaderContext.php.

References $image, $modules, getModules(), and getResourceLoader().

◆ getLanguage()

ResourceLoaderContext::getLanguage ( )

◆ getLogger()

ResourceLoaderContext::getLogger ( )
Since
1.27
Returns
\Psr\Log\LoggerInterface

Definition at line 163 of file ResourceLoaderContext.php.

◆ getModules()

ResourceLoaderContext::getModules ( )
Returns
array

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 170 of file ResourceLoaderContext.php.

References $modules.

Referenced by getImageObj().

◆ getOnly()

ResourceLoaderContext::getOnly ( )
Returns
string|null

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 268 of file ResourceLoaderContext.php.

Referenced by getHash(), shouldIncludeMessages(), shouldIncludeScripts(), and shouldIncludeStyles().

◆ getRaw()

ResourceLoaderContext::getRaw ( )
Returns
bool

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 284 of file ResourceLoaderContext.php.

Referenced by getHash(), and ResourceLoaderClientHtml\makeLoad().

◆ getRequest()

ResourceLoaderContext::getRequest ( )
Returns
WebRequest

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 155 of file ResourceLoaderContext.php.

References $request.

Referenced by getDirection(), and getLanguage().

◆ getResourceLoader()

ResourceLoaderContext::getResourceLoader ( )

◆ getSkin()

ResourceLoaderContext::getSkin ( )
Returns
string

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 208 of file ResourceLoaderContext.php.

References $skin.

◆ getUser()

ResourceLoaderContext::getUser ( )
Returns
string|null

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 215 of file ResourceLoaderContext.php.

References $user.

Referenced by getHash(), and getUserObj().

◆ getUserObj()

ResourceLoaderContext::getUserObj ( )

Get the possibly-cached User object for the specified username.

Since
1.25
Returns
User

Definition at line 243 of file ResourceLoaderContext.php.

References $username, getUser(), and User\newFromName().

◆ getVariant()

ResourceLoaderContext::getVariant ( )
Returns
string|null

Definition at line 298 of file ResourceLoaderContext.php.

Referenced by getHash().

◆ getVersion()

ResourceLoaderContext::getVersion ( )
See also
ResourceLoaderModule::getVersionHash
ResourceLoaderClientHtml::makeLoad
Returns
string|null

Reimplemented in DerivativeResourceLoaderContext.

Definition at line 277 of file ResourceLoaderContext.php.

Referenced by getHash().

◆ msg()

ResourceLoaderContext::msg ( $key)

Get a Message object with context set.

See wfMessage for parameters.

Since
1.27
Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of keys, or a MessageSpecifier.
mixed$args,...
Returns
Message

Implements MessageLocalizer.

Definition at line 228 of file ResourceLoaderContext.php.

References getLanguage().

◆ newDummyContext()

static ResourceLoaderContext::newDummyContext ( )
static

Return a dummy ResourceLoaderContext object suitable for passing into things that don't "really" need a context.

Returns
ResourceLoaderContext

Definition at line 138 of file ResourceLoaderContext.php.

◆ shouldIncludeMessages()

ResourceLoaderContext::shouldIncludeMessages ( )
Returns
bool

Definition at line 361 of file ResourceLoaderContext.php.

References getOnly().

◆ shouldIncludeScripts()

ResourceLoaderContext::shouldIncludeScripts ( )
Returns
bool

Definition at line 347 of file ResourceLoaderContext.php.

References getOnly().

◆ shouldIncludeStyles()

ResourceLoaderContext::shouldIncludeStyles ( )
Returns
bool

Definition at line 354 of file ResourceLoaderContext.php.

References getOnly().

Member Data Documentation

◆ $debug

ResourceLoaderContext::$debug
protected

Definition at line 40 of file ResourceLoaderContext.php.

◆ $direction

ResourceLoaderContext::$direction
protected

Definition at line 52 of file ResourceLoaderContext.php.

◆ $format

ResourceLoaderContext::$format
protected

Definition at line 50 of file ResourceLoaderContext.php.

◆ $hash

ResourceLoaderContext::$hash
protected

Definition at line 53 of file ResourceLoaderContext.php.

◆ $image

ResourceLoaderContext::$image
protected

Definition at line 48 of file ResourceLoaderContext.php.

◆ $imageObj

ResourceLoaderContext::$imageObj
protected

Definition at line 55 of file ResourceLoaderContext.php.

◆ $language

ResourceLoaderContext::$language
protected

Definition at line 39 of file ResourceLoaderContext.php.

◆ $logger

ResourceLoaderContext::$logger
protected

Definition at line 35 of file ResourceLoaderContext.php.

◆ $modules

ResourceLoaderContext::$modules
protected

Definition at line 44 of file ResourceLoaderContext.php.

◆ $only

ResourceLoaderContext::$only
protected

Definition at line 45 of file ResourceLoaderContext.php.

◆ $raw

ResourceLoaderContext::$raw
protected

Definition at line 47 of file ResourceLoaderContext.php.

◆ $request

ResourceLoaderContext::$request
protected

Definition at line 34 of file ResourceLoaderContext.php.

◆ $resourceLoader

ResourceLoaderContext::$resourceLoader
protected

Definition at line 33 of file ResourceLoaderContext.php.

◆ $skin

ResourceLoaderContext::$skin
protected

Definition at line 38 of file ResourceLoaderContext.php.

◆ $user

ResourceLoaderContext::$user
protected

Definition at line 41 of file ResourceLoaderContext.php.

◆ $userObj

ResourceLoaderContext::$userObj
protected

Definition at line 54 of file ResourceLoaderContext.php.

◆ $variant

ResourceLoaderContext::$variant
protected

Definition at line 49 of file ResourceLoaderContext.php.

◆ $version

ResourceLoaderContext::$version
protected

Definition at line 46 of file ResourceLoaderContext.php.


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