MediaWiki  master
DerivativeResourceLoaderContext Class Reference

A mutable version of ResourceLoaderContext. More...

Inheritance diagram for DerivativeResourceLoaderContext:
Collaboration diagram for DerivativeResourceLoaderContext:

Public Member Functions

 __construct (ResourceLoaderContext $context)
 
 getContentOverrideCallback ()
 Return the replaced-content mapping callback. More...
 
 getDebug ()
 
 getDirection ()
 
 getLanguage ()
 
 getModules ()
 
 getOnly ()
 
 getRaw ()
 
 getRequest ()
 
 getResourceLoader ()
 
 getSkin ()
 
 getUser ()
 
 getUserIdentity ()
 Get the possibly-cached UserIdentity object for the specified username. More...
 
 getUserObj ()
 Get the possibly-cached User object for the specified username. More...
 
 getVersion ()
 
 setContentOverrideCallback ( $callback)
 
 setDebug (int $debug)
 
 setDirection (string $direction)
 
 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 ResourceLoaderContext
 __construct (ResourceLoader $resourceLoader, WebRequest $request)
 
 encodeJson ( $data)
 Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode. More...
 
 getConfig ()
 
 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...
 
 getLogger ()
 
 getReqBase ()
 Get the request base parameters, omitting any defaults. More...
 
 getVariant ()
 
 msg ( $key,... $params)
 Get a Message object with context set. More...
 
 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 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 ResourceLoaderContext
int $debug
 
string null $direction
 
string null $format
 
string null $hash
 
string null $image
 
ResourceLoaderImage false $imageObj
 
string $language
 
LoggerInterface $logger
 
string[] $modules
 
string null $only
 
bool $raw
 
WebRequest $request
 
ResourceLoader $resourceLoader
 
string $skin
 
string null $user
 
UserIdentity null false $userIdentity = false
 
User null $userObj
 
string null $variant
 
string null $version
 

Private Attributes

ResourceLoaderContext $context
 
const INHERIT_VALUE = -1
 

Additional Inherited Members

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

Detailed Description

A mutable version of ResourceLoaderContext.

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

Since
1.24

Definition at line 35 of file DerivativeResourceLoaderContext.php.

Constructor & Destructor Documentation

◆ __construct()

DerivativeResourceLoaderContext::__construct ( ResourceLoaderContext  $context)

Definition at line 68 of file DerivativeResourceLoaderContext.php.

References $context.

Member Function Documentation

◆ getContentOverrideCallback()

DerivativeResourceLoaderContext::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 )

Reimplemented from ResourceLoaderContext.

Definition at line 242 of file DerivativeResourceLoaderContext.php.

◆ getDebug()

DerivativeResourceLoaderContext::getDebug ( )

Reimplemented from ResourceLoaderContext.

Definition at line 181 of file DerivativeResourceLoaderContext.php.

◆ getDirection()

DerivativeResourceLoaderContext::getDirection ( )

Reimplemented from ResourceLoaderContext.

Definition at line 101 of file DerivativeResourceLoaderContext.php.

◆ getLanguage()

DerivativeResourceLoaderContext::getLanguage ( )

Reimplemented from ResourceLoaderContext.

Definition at line 87 of file DerivativeResourceLoaderContext.php.

◆ getModules()

DerivativeResourceLoaderContext::getModules ( )

Reimplemented from ResourceLoaderContext.

Definition at line 72 of file DerivativeResourceLoaderContext.php.

◆ getOnly()

DerivativeResourceLoaderContext::getOnly ( )
Returns
string|null

Reimplemented from ResourceLoaderContext.

Definition at line 193 of file DerivativeResourceLoaderContext.php.

◆ getRaw()

DerivativeResourceLoaderContext::getRaw ( )

Reimplemented from ResourceLoaderContext.

Definition at line 223 of file DerivativeResourceLoaderContext.php.

◆ getRequest()

DerivativeResourceLoaderContext::getRequest ( )

Reimplemented from ResourceLoaderContext.

Definition at line 234 of file DerivativeResourceLoaderContext.php.

◆ getResourceLoader()

DerivativeResourceLoaderContext::getResourceLoader ( )

Reimplemented from ResourceLoaderContext.

Definition at line 238 of file DerivativeResourceLoaderContext.php.

◆ getSkin()

DerivativeResourceLoaderContext::getSkin ( )

Reimplemented from ResourceLoaderContext.

Definition at line 117 of file DerivativeResourceLoaderContext.php.

◆ getUser()

DerivativeResourceLoaderContext::getUser ( )
Returns
string|null

Reimplemented from ResourceLoaderContext.

Definition at line 129 of file DerivativeResourceLoaderContext.php.

◆ getUserIdentity()

DerivativeResourceLoaderContext::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 ResourceLoaderContext.

Definition at line 136 of file DerivativeResourceLoaderContext.php.

◆ getUserObj()

DerivativeResourceLoaderContext::getUserObj ( )

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

Since
1.25
Returns
User

Reimplemented from ResourceLoaderContext.

Definition at line 155 of file DerivativeResourceLoaderContext.php.

◆ getVersion()

DerivativeResourceLoaderContext::getVersion ( )

◆ setContentOverrideCallback()

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

Definition at line 255 of file DerivativeResourceLoaderContext.php.

◆ setDebug()

DerivativeResourceLoaderContext::setDebug ( int  $debug)

Definition at line 188 of file DerivativeResourceLoaderContext.php.

References $debug.

◆ setDirection()

DerivativeResourceLoaderContext::setDirection ( string  $direction)

Definition at line 112 of file DerivativeResourceLoaderContext.php.

◆ setLanguage()

DerivativeResourceLoaderContext::setLanguage ( string  $language)

Definition at line 94 of file DerivativeResourceLoaderContext.php.

◆ setModules()

DerivativeResourceLoaderContext::setModules ( array  $modules)
Parameters
string[]$modules

Definition at line 83 of file DerivativeResourceLoaderContext.php.

References $modules.

◆ setOnly()

DerivativeResourceLoaderContext::setOnly ( ?string  $only)
Parameters
string | null$only

Definition at line 203 of file DerivativeResourceLoaderContext.php.

◆ setRaw()

DerivativeResourceLoaderContext::setRaw ( bool  $raw)

Definition at line 230 of file DerivativeResourceLoaderContext.php.

◆ setSkin()

DerivativeResourceLoaderContext::setSkin ( string  $skin)

Definition at line 124 of file DerivativeResourceLoaderContext.php.

◆ setUser()

DerivativeResourceLoaderContext::setUser ( ?string  $user)
Parameters
string | null$user

Definition at line 173 of file DerivativeResourceLoaderContext.php.

◆ setVersion()

DerivativeResourceLoaderContext::setVersion ( ?string  $version)
Parameters
string | null$version

Definition at line 218 of file DerivativeResourceLoaderContext.php.

Member Data Documentation

◆ $contentOverrideCallback

int callable null DerivativeResourceLoaderContext::$contentOverrideCallback = self::INHERIT_VALUE
protected

Definition at line 66 of file DerivativeResourceLoaderContext.php.

◆ $context

ResourceLoaderContext DerivativeResourceLoaderContext::$context
private

Definition at line 41 of file DerivativeResourceLoaderContext.php.

Referenced by __construct().

◆ $debug

int DerivativeResourceLoaderContext::$debug = self::INHERIT_VALUE
protected

Definition at line 58 of file DerivativeResourceLoaderContext.php.

◆ $direction

int string null DerivativeResourceLoaderContext::$direction = self::INHERIT_VALUE
protected

Definition at line 48 of file DerivativeResourceLoaderContext.php.

◆ $language

int string DerivativeResourceLoaderContext::$language = self::INHERIT_VALUE
protected

Definition at line 46 of file DerivativeResourceLoaderContext.php.

◆ $modules

int string [] DerivativeResourceLoaderContext::$modules = self::INHERIT_VALUE
protected

Definition at line 44 of file DerivativeResourceLoaderContext.php.

◆ $only

int string null DerivativeResourceLoaderContext::$only = self::INHERIT_VALUE
protected

Definition at line 60 of file DerivativeResourceLoaderContext.php.

◆ $raw

int bool DerivativeResourceLoaderContext::$raw = self::INHERIT_VALUE
protected

Definition at line 64 of file DerivativeResourceLoaderContext.php.

◆ $skin

int string DerivativeResourceLoaderContext::$skin = self::INHERIT_VALUE
protected

Definition at line 50 of file DerivativeResourceLoaderContext.php.

◆ $user

int string null DerivativeResourceLoaderContext::$user = self::INHERIT_VALUE
protected

Definition at line 52 of file DerivativeResourceLoaderContext.php.

◆ $userIdentity

int UserIdentity null false DerivativeResourceLoaderContext::$userIdentity = self::INHERIT_VALUE
protected

Definition at line 54 of file DerivativeResourceLoaderContext.php.

◆ $userObj

int User null DerivativeResourceLoaderContext::$userObj = self::INHERIT_VALUE
protected

Definition at line 56 of file DerivativeResourceLoaderContext.php.

◆ $version

int string null DerivativeResourceLoaderContext::$version = self::INHERIT_VALUE
protected

Definition at line 62 of file DerivativeResourceLoaderContext.php.

◆ INHERIT_VALUE

const DerivativeResourceLoaderContext::INHERIT_VALUE = -1
private

Definition at line 36 of file DerivativeResourceLoaderContext.php.


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