MediaWiki master
MediaWiki\ResourceLoader\DerivativeContext Class Reference

A mutable version of Context. More...

Inherits MediaWiki\ResourceLoader\Context.

Collaboration diagram for MediaWiki\ResourceLoader\DerivativeContext:

Public Member Functions

 __construct (Context $context)
 
 getContentOverrideCallback ()
 Return the replaced-content mapping callback.
 
 getDebug ()
 
 getDirection ()
 
 getLanguage ()
 
 getModules ()
 
 getOnly ()
 
 getRaw ()
 
 getRequest ()
 
 getResourceLoader ()
 
 getSkin ()
 
 getUser ()
 
 getUserIdentity ()
 Get the possibly-cached UserIdentity object for the specified username.
 
 getUserObj ()
 Get the possibly-cached User object for the specified username.
 
 getVersion ()
 
 isSourceMap ()
 
 setContentOverrideCallback ( $callback)
 
 setDebug (int $debug)
 
 setDirection (string $direction)
 
 setIsSourceMap (bool $sourcemap)
 
 setLanguage (string $language)
 
 setModules (array $modules)
 
 setOnly (?string $only)
 
 setRaw (bool $raw)
 
 setSkin (string $skin)
 
 setUser (?string $user)
 
 setVersion (?string $version)
 
- Public Member Functions inherited from MediaWiki\ResourceLoader\Context
 __construct (ResourceLoader $resourceLoader, WebRequest $request, $validSkins=null)
 
 encodeJson ( $data)
 Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
 
 getFormat ()
 
 getHash ()
 All factors that uniquely identify this request, except 'modules'.
 
 getImage ()
 
 getImageObj ()
 If this is a request for an image, get the Image object.
 
 getLogger ()
 
 getReqBase ()
 Get the request base parameters, omitting any defaults.
 
 getVariant ()
 
 msg ( $key,... $params)
 Get a Message object with context set.
 
 shouldIncludeMessages ()
 
 shouldIncludeScripts ()
 
 shouldIncludeStyles ()
 

Protected Attributes

int callable null $contentOverrideCallback = self::INHERIT_VALUE
 
int $debug = self::INHERIT_VALUE
 
int string null $direction = self::INHERIT_VALUE
 
int string $language = self::INHERIT_VALUE
 
int string[] $modules = self::INHERIT_VALUE
 
int string null $only = self::INHERIT_VALUE
 
int bool $raw = self::INHERIT_VALUE
 
int string $skin = self::INHERIT_VALUE
 
int bool $sourcemap = self::INHERIT_VALUE
 
int string null $user = self::INHERIT_VALUE
 
int UserIdentity null false $userIdentity = self::INHERIT_VALUE
 
int User null $userObj = self::INHERIT_VALUE
 
int string null $version = self::INHERIT_VALUE
 
- Protected Attributes inherited from MediaWiki\ResourceLoader\Context
int $debug
 
string null $direction
 
string null $format
 
string null $hash
 
string null $image
 
Image false $imageObj
 
string $language
 
LoggerInterface $logger
 
string[] $modules
 
string null $only
 
bool $raw
 
WebRequest $request
 
ResourceLoader $resourceLoader
 
string $skin
 
bool $sourcemap
 
string null $user
 
UserIdentity null false $userIdentity = false
 
User null $userObj
 
string null $variant
 
string null $version
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\ResourceLoader\Context
static debugFromString (?string $debug)
 
static newDummyContext ()
 Return a dummy Context object suitable for passing into things that don't "really" need a context.
 
- Public Attributes inherited from MediaWiki\ResourceLoader\Context
const DEBUG_LEGACY = 1
 
const DEBUG_MAIN = 2
 
const DEBUG_OFF = 0
 
const DEFAULT_LANG = 'qqx'
 
const DEFAULT_SKIN = 'fallback'
 

Detailed Description

A mutable version of Context.

Allows changing specific properties of a context object, without changing the main one. Inspired by MediaWiki's DerivativeContext.

Since
1.24

Definition at line 39 of file DerivativeContext.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\ResourceLoader\DerivativeContext::__construct ( Context $context)

Definition at line 74 of file DerivativeContext.php.

Member Function Documentation

◆ getContentOverrideCallback()

MediaWiki\ResourceLoader\DerivativeContext::getContentOverrideCallback ( )

Return the replaced-content mapping callback.

When editing a page that's used to generate the scripts or styles of a WikiModule, 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 )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 259 of file DerivativeContext.php.

◆ getDebug()

MediaWiki\ResourceLoader\DerivativeContext::getDebug ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 187 of file DerivativeContext.php.

◆ getDirection()

MediaWiki\ResourceLoader\DerivativeContext::getDirection ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 107 of file DerivativeContext.php.

◆ getLanguage()

MediaWiki\ResourceLoader\DerivativeContext::getLanguage ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 93 of file DerivativeContext.php.

◆ getModules()

MediaWiki\ResourceLoader\DerivativeContext::getModules ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 78 of file DerivativeContext.php.

◆ getOnly()

MediaWiki\ResourceLoader\DerivativeContext::getOnly ( )
Returns
string|null

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 199 of file DerivativeContext.php.

◆ getRaw()

MediaWiki\ResourceLoader\DerivativeContext::getRaw ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 229 of file DerivativeContext.php.

◆ getRequest()

MediaWiki\ResourceLoader\DerivativeContext::getRequest ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 251 of file DerivativeContext.php.

◆ getResourceLoader()

MediaWiki\ResourceLoader\DerivativeContext::getResourceLoader ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 255 of file DerivativeContext.php.

◆ getSkin()

MediaWiki\ResourceLoader\DerivativeContext::getSkin ( )

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 123 of file DerivativeContext.php.

◆ getUser()

MediaWiki\ResourceLoader\DerivativeContext::getUser ( )
Returns
string|null

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 135 of file DerivativeContext.php.

◆ getUserIdentity()

MediaWiki\ResourceLoader\DerivativeContext::getUserIdentity ( )

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

This will be null on most requests, except for load.php requests that have a 'user' parameter set.

Since
1.38
Returns
UserIdentity|null

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 142 of file DerivativeContext.php.

◆ getUserObj()

MediaWiki\ResourceLoader\DerivativeContext::getUserObj ( )

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

Since
1.25
Returns
User

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 161 of file DerivativeContext.php.

◆ getVersion()

MediaWiki\ResourceLoader\DerivativeContext::getVersion ( )
See also
Module::getVersionHash
ClientHtml::makeLoad
Returns
string|null

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 214 of file DerivativeContext.php.

◆ isSourceMap()

MediaWiki\ResourceLoader\DerivativeContext::isSourceMap ( )
Since
1.41
Returns
bool

Reimplemented from MediaWiki\ResourceLoader\Context.

Definition at line 240 of file DerivativeContext.php.

◆ setContentOverrideCallback()

MediaWiki\ResourceLoader\DerivativeContext::setContentOverrideCallback ( $callback)
See also
self::getContentOverrideCallback
Since
1.32
Parameters
callable | null | int$callbackAs per self::getContentOverrideCallback, or self::INHERIT_VALUE

Definition at line 272 of file DerivativeContext.php.

◆ setDebug()

MediaWiki\ResourceLoader\DerivativeContext::setDebug ( int $debug)

Definition at line 194 of file DerivativeContext.php.

◆ setDirection()

MediaWiki\ResourceLoader\DerivativeContext::setDirection ( string $direction)

Definition at line 118 of file DerivativeContext.php.

◆ setIsSourceMap()

MediaWiki\ResourceLoader\DerivativeContext::setIsSourceMap ( bool $sourcemap)

Definition at line 247 of file DerivativeContext.php.

◆ setLanguage()

MediaWiki\ResourceLoader\DerivativeContext::setLanguage ( string $language)

Definition at line 100 of file DerivativeContext.php.

◆ setModules()

MediaWiki\ResourceLoader\DerivativeContext::setModules ( array $modules)
Parameters
string[]$modules

Definition at line 89 of file DerivativeContext.php.

◆ setOnly()

MediaWiki\ResourceLoader\DerivativeContext::setOnly ( ?string $only)
Parameters
string | null$only

Definition at line 209 of file DerivativeContext.php.

◆ setRaw()

MediaWiki\ResourceLoader\DerivativeContext::setRaw ( bool $raw)

Definition at line 236 of file DerivativeContext.php.

◆ setSkin()

MediaWiki\ResourceLoader\DerivativeContext::setSkin ( string $skin)

Definition at line 130 of file DerivativeContext.php.

◆ setUser()

MediaWiki\ResourceLoader\DerivativeContext::setUser ( ?string $user)
Parameters
string | null$user

Definition at line 179 of file DerivativeContext.php.

◆ setVersion()

MediaWiki\ResourceLoader\DerivativeContext::setVersion ( ?string $version)
Parameters
string | null$version

Definition at line 224 of file DerivativeContext.php.

Member Data Documentation

◆ $contentOverrideCallback

int callable null MediaWiki\ResourceLoader\DerivativeContext::$contentOverrideCallback = self::INHERIT_VALUE
protected

Definition at line 72 of file DerivativeContext.php.

◆ $debug

int MediaWiki\ResourceLoader\DerivativeContext::$debug = self::INHERIT_VALUE
protected

Definition at line 62 of file DerivativeContext.php.

◆ $direction

int string null MediaWiki\ResourceLoader\DerivativeContext::$direction = self::INHERIT_VALUE
protected

Definition at line 52 of file DerivativeContext.php.

◆ $language

int string MediaWiki\ResourceLoader\DerivativeContext::$language = self::INHERIT_VALUE
protected

Definition at line 50 of file DerivativeContext.php.

◆ $modules

int string [] MediaWiki\ResourceLoader\DerivativeContext::$modules = self::INHERIT_VALUE
protected

Definition at line 48 of file DerivativeContext.php.

◆ $only

int string null MediaWiki\ResourceLoader\DerivativeContext::$only = self::INHERIT_VALUE
protected

Definition at line 64 of file DerivativeContext.php.

◆ $raw

int bool MediaWiki\ResourceLoader\DerivativeContext::$raw = self::INHERIT_VALUE
protected

Definition at line 68 of file DerivativeContext.php.

◆ $skin

int string MediaWiki\ResourceLoader\DerivativeContext::$skin = self::INHERIT_VALUE
protected

Definition at line 54 of file DerivativeContext.php.

◆ $sourcemap

int bool MediaWiki\ResourceLoader\DerivativeContext::$sourcemap = self::INHERIT_VALUE
protected

Definition at line 70 of file DerivativeContext.php.

◆ $user

int string null MediaWiki\ResourceLoader\DerivativeContext::$user = self::INHERIT_VALUE
protected

Definition at line 56 of file DerivativeContext.php.

◆ $userIdentity

int UserIdentity null false MediaWiki\ResourceLoader\DerivativeContext::$userIdentity = self::INHERIT_VALUE
protected

Definition at line 58 of file DerivativeContext.php.

◆ $userObj

int User null MediaWiki\ResourceLoader\DerivativeContext::$userObj = self::INHERIT_VALUE
protected

Definition at line 60 of file DerivativeContext.php.

◆ $version

int string null MediaWiki\ResourceLoader\DerivativeContext::$version = self::INHERIT_VALUE
protected

Definition at line 66 of file DerivativeContext.php.


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