MediaWiki  master
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)
 
 getConfig ()
 
 getContentOverrideCallback ()
 Return the replaced-content mapping callback. More...
 
 getDebug ()
 
 getDirection ()
 
 getFormat ()
 
 getHash ()
 All factors that uniquely identify this request, except 'modules'. More...
 
 getImage ()
 
 getImageObj ()
 If this is a request for an image, get the ResourceLoaderImage object. More...
 
 getLanguage ()
 
 getLogger ()
 
 getModules ()
 
 getOnly ()
 
 getRaw ()
 
 getReqBase ()
 Get the request base parameters, omitting any defaults. More...
 
 getRequest ()
 
 getResourceLoader ()
 
 getSkin ()
 
 getUser ()
 
 getUserObj ()
 Get the possibly-cached User object for the specified username. More...
 
 getVariant ()
 
 getVersion ()
 
 msg ( $key)
 Get a Message object with context set. More...
 
 shouldIncludeMessages ()
 
 shouldIncludeScripts ()
 
 shouldIncludeStyles ()
 

Static Public Member Functions

static newDummyContext ()
 Return a dummy ResourceLoaderContext object suitable for passing into things that don't "really" need a context. More...
 

Public Attributes

const DEFAULT_LANG = 'qqx'
 
const DEFAULT_SKIN = 'fallback'
 

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 
)

Member Function Documentation

◆ getConfig()

ResourceLoaderContext::getConfig ( )
Deprecated:
since 1.34 Use ResourceLoaderModule::getConfig instead inside module methods.

Use ResourceLoader::getConfig elsewhere.

Returns
Config

Definition at line 132 of file ResourceLoaderContext.php.

References getResourceLoader(), and wfDeprecated().

◆ getContentOverrideCallback()

ResourceLoaderContext::getContentOverrideCallback ( )

Return the replaced-content mapping callback.

When editing a page that's used to generate the scripts or styles of a ResourceLoaderWikiModule, a preview should use the to-be-saved version of the page rather than the current version in the database. A context supporting such previews should return a callback to return these mappings here.

Since
1.32
Returns
callable|null Signature is Content|null func( Title $t )

Definition at line 347 of file ResourceLoaderContext.php.

References null.

Referenced by ResourceLoaderWikiModule\getTitleInfo(), ResourceLoaderClientHtml\makeContext(), and ResourceLoaderWikiModule\shouldEmbedModule().

◆ getDebug()

◆ getDirection()

ResourceLoaderContext::getDirection ( )
Returns
string

Definition at line 183 of file ResourceLoaderContext.php.

References $direction, Language\factory(), getLanguage(), getRequest(), and null.

Referenced by ResourceLoaderImage\getPath().

◆ getFormat()

ResourceLoaderContext::getFormat ( )
Returns
string|null

Definition at line 296 of file ResourceLoaderContext.php.

References $format.

Referenced by getHash(), ResourceLoaderImage\getImageData(), and ResourceLoaderImage\sendResponseHeaders().

◆ 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 383 of file ResourceLoaderContext.php.

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

Referenced by ResourceLoaderFileModule\expandPackageFiles(), ResourceLoaderModule\getModuleContent(), ResourceLoaderModule\getVersionHash(), and ResourceFileCache\newFromContext().

◆ getImage()

ResourceLoaderContext::getImage ( )
Returns
string|null

Definition at line 282 of file ResourceLoaderContext.php.

References $image.

Referenced by getHash(), and ResourceFileCache\newFromContext().

◆ 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 306 of file ResourceLoaderContext.php.

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

Referenced by ResourceLoader\makeModuleResponse(), ResourceLoader\respond(), and ResourceLoader\sendResponseHeaders().

◆ getLanguage()

◆ getLogger()

ResourceLoaderContext::getLogger ( )
Deprecated:
since 1.34 Use ResourceLoaderModule::getLogger instead inside module methods.

Use ResourceLoader::getLogger elsewhere.

Since
1.27
Returns
\Psr\Log\LoggerInterface

Definition at line 150 of file ResourceLoaderContext.php.

References $logger.

◆ getModules()

ResourceLoaderContext::getModules ( )

◆ getOnly()

◆ getRaw()

ResourceLoaderContext::getRaw ( )
Returns
bool

Definition at line 275 of file ResourceLoaderContext.php.

References $raw.

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

◆ getReqBase()

ResourceLoaderContext::getReqBase ( )

Get the request base parameters, omitting any defaults.

Definition at line 409 of file ResourceLoaderContext.php.

References getDebug(), getLanguage(), and getSkin().

Referenced by ResourceLoaderStartUpModule\getScript().

◆ getRequest()

◆ getResourceLoader()

◆ getSkin()

◆ getUser()

ResourceLoaderContext::getUser ( )
Returns
string|null

Definition at line 206 of file ResourceLoaderContext.php.

References $user.

Referenced by getHash(), getUserObj(), and ResourceLoader\isEmptyObject().

◆ getUserObj()

ResourceLoaderContext::getUserObj ( )

◆ getVariant()

ResourceLoaderContext::getVariant ( )
Returns
string|null

Definition at line 289 of file ResourceLoaderContext.php.

References $variant.

Referenced by getHash(), and ResourceLoaderImage\getImageData().

◆ getVersion()

◆ msg()

ResourceLoaderContext::msg (   $key)

Get a Message object with context set.

See wfMessage for parameters.

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

Implements MessageLocalizer.

Definition at line 219 of file ResourceLoaderContext.php.

References getLanguage(), Title\newFromText(), and wfMessage().

◆ newDummyContext()

static ResourceLoaderContext::newDummyContext ( )
static

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

Use cases:

  • Unit tests (deprecated, create empty instance directly or use RLTestCase).
Returns
ResourceLoaderContext

Definition at line 107 of file ResourceLoaderContext.php.

Referenced by ResourceLoaderContextTest\testDummy(), and ResourceLoaderWikiModuleTest\testGetPages().

◆ shouldIncludeMessages()

ResourceLoaderContext::shouldIncludeMessages ( )
Returns
bool

Definition at line 368 of file ResourceLoaderContext.php.

References getOnly(), and null.

◆ shouldIncludeScripts()

ResourceLoaderContext::shouldIncludeScripts ( )
Returns
bool

Definition at line 354 of file ResourceLoaderContext.php.

References getOnly(), and null.

Referenced by ResourceLoader\makeModuleResponse(), and ResourceLoader\respond().

◆ shouldIncludeStyles()

ResourceLoaderContext::shouldIncludeStyles ( )
Returns
bool

Definition at line 361 of file ResourceLoaderContext.php.

References getOnly(), and null.

Member Data Documentation

◆ $debug

ResourceLoaderContext::$debug
protected

Definition at line 43 of file ResourceLoaderContext.php.

Referenced by getDebug().

◆ $direction

ResourceLoaderContext::$direction
protected

Definition at line 55 of file ResourceLoaderContext.php.

Referenced by getDirection().

◆ $format

ResourceLoaderContext::$format
protected

Definition at line 53 of file ResourceLoaderContext.php.

Referenced by getFormat().

◆ $hash

ResourceLoaderContext::$hash
protected

Definition at line 56 of file ResourceLoaderContext.php.

Referenced by getHash().

◆ $image

ResourceLoaderContext::$image
protected

Definition at line 51 of file ResourceLoaderContext.php.

Referenced by getImage(), and getImageObj().

◆ $imageObj

ResourceLoaderContext::$imageObj
protected

Definition at line 58 of file ResourceLoaderContext.php.

Referenced by getImageObj().

◆ $language

ResourceLoaderContext::$language
protected

Definition at line 42 of file ResourceLoaderContext.php.

Referenced by getLanguage().

◆ $logger

ResourceLoaderContext::$logger
protected

Definition at line 38 of file ResourceLoaderContext.php.

Referenced by getLogger().

◆ $modules

ResourceLoaderContext::$modules
protected

Definition at line 47 of file ResourceLoaderContext.php.

Referenced by __construct(), getImageObj(), and getModules().

◆ $only

ResourceLoaderContext::$only
protected

Definition at line 48 of file ResourceLoaderContext.php.

Referenced by getOnly().

◆ $raw

ResourceLoaderContext::$raw
protected

Definition at line 50 of file ResourceLoaderContext.php.

Referenced by getRaw().

◆ $request

ResourceLoaderContext::$request
protected

Definition at line 37 of file ResourceLoaderContext.php.

Referenced by __construct(), and getRequest().

◆ $resourceLoader

ResourceLoaderContext::$resourceLoader
protected

Definition at line 36 of file ResourceLoaderContext.php.

Referenced by __construct(), and getResourceLoader().

◆ $skin

ResourceLoaderContext::$skin
protected

Definition at line 41 of file ResourceLoaderContext.php.

Referenced by getSkin().

◆ $user

ResourceLoaderContext::$user
protected

Definition at line 44 of file ResourceLoaderContext.php.

Referenced by getUser().

◆ $userObj

ResourceLoaderContext::$userObj
protected

Definition at line 57 of file ResourceLoaderContext.php.

Referenced by getUserObj().

◆ $variant

ResourceLoaderContext::$variant
protected

Definition at line 52 of file ResourceLoaderContext.php.

Referenced by getVariant().

◆ $version

ResourceLoaderContext::$version
protected

Definition at line 49 of file ResourceLoaderContext.php.

Referenced by getVersion().

◆ DEFAULT_LANG

const ResourceLoaderContext::DEFAULT_LANG = 'qqx'

Definition at line 33 of file ResourceLoaderContext.php.

Referenced by ResourceLoader\isEmptyObject().

◆ DEFAULT_SKIN

const ResourceLoaderContext::DEFAULT_SKIN = 'fallback'

Definition at line 34 of file ResourceLoaderContext.php.

Referenced by ResourceLoader\isEmptyObject().


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