MediaWiki master
|
Context object that contains information about the state of a specific ResourceLoader web request. More...
Inherits MessageLocalizer.
Inherited by MediaWiki\ResourceLoader\DerivativeContext.
Public Member Functions | |
__construct (ResourceLoader $resourceLoader, WebRequest $request, $validSkins=null) | |
encodeJson ( $data) | |
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode. | |
getContentOverrideCallback () | |
Return the replaced-content mapping callback. | |
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 Image object. | |
getLanguage () | |
getLogger () | |
getModules () | |
getOnly () | |
getRaw () | |
getReqBase () | |
Get the request base parameters, omitting any defaults. | |
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. | |
getVariant () | |
getVersion () | |
isSourceMap () | |
msg ( $key,... $params) | |
Get a Message object with context set. | |
shouldIncludeMessages () | |
shouldIncludeScripts () | |
shouldIncludeStyles () | |
Static Public Member Functions | |
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 | |
const | DEBUG_LEGACY = 1 |
const | DEBUG_MAIN = 2 |
const | DEBUG_OFF = 0 |
const | DEFAULT_LANG = 'qqx' |
const | DEFAULT_SKIN = 'fallback' |
Protected Attributes | |
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 |
Context object that contains information about the state of a specific ResourceLoader web request.
Passed around to Module methods.
Definition at line 45 of file Context.php.
MediaWiki\ResourceLoader\Context::__construct | ( | ResourceLoader | $resourceLoader, |
WebRequest | $request, | ||
$validSkins = null ) |
ResourceLoader | $resourceLoader | |
WebRequest | $request | |
string[] | null | $validSkins | List of valid skin names. If not passed, any skin name is considered valid. Invalid skins are replaced by the default. |
Definition at line 108 of file Context.php.
References MediaWiki\ResourceLoader\Context\$modules, MediaWiki\ResourceLoader\Context\$request, MediaWiki\ResourceLoader\Context\$resourceLoader, MediaWiki\ResourceLoader\Context\debugFromString(), MediaWiki\ResourceLoader\Context\DEFAULT_SKIN, MediaWiki\ResourceLoader\ResourceLoader\expandModuleNames(), MediaWiki\Request\WebRequest\getFuzzyBool(), MediaWiki\ResourceLoader\ResourceLoader\getLogger(), and MediaWiki\Request\WebRequest\getRawVal().
|
static |
string | null | $debug |
Definition at line 152 of file Context.php.
References MediaWiki\ResourceLoader\Context\DEBUG_LEGACY.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
MediaWiki\ResourceLoader\Context::encodeJson | ( | $data | ) |
Wrapper around json_encode that avoids needless escapes, and pretty-prints in debug mode.
mixed | $data |
Definition at line 497 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Module\getDeprecationInformation(), MediaWiki\ResourceLoader\StartUpModule\getScript(), MediaWiki\ResourceLoader\UserOptionsModule\getScript(), MediaWiki\ResourceLoader\ClientHtml\makeLoad(), MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::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.
Content|null func( Title $t )
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 419 of file Context.php.
Referenced by MediaWiki\ResourceLoader\WikiModule\getContentObj(), MediaWiki\ResourceLoader\WikiModule\getTitleInfo(), and MediaWiki\ResourceLoader\WikiModule\shouldEmbedModule().
MediaWiki\ResourceLoader\Context::getDebug | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 319 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Module\buildContent(), MediaWiki\ResourceLoader\StartUpModule\getScript(), MediaWiki\ResourceLoader\Module\getVersionHash(), MediaWiki\ResourceLoader\ClientHtml\makeLoad(), MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), MediaWiki\ResourceLoader\ResourceLoader\respond(), and MediaWiki\ResourceLoader\ResourceLoader\tryRespondNotModified().
MediaWiki\ResourceLoader\Context::getDirection | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 228 of file Context.php.
References getRequest().
Referenced by MediaWiki\ResourceLoader\FileModule\getFlip(), MediaWiki\ResourceLoader\Module\getFlip(), and MediaWiki\ResourceLoader\Image\getPath().
MediaWiki\ResourceLoader\Context::getFormat | ( | ) |
Definition at line 368 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Image\getImageData().
MediaWiki\ResourceLoader\Context::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 response output.
Definition at line 446 of file Context.php.
References getUser().
Referenced by MediaWiki\ResourceLoader\Module\getModuleContent(), MediaWiki\ResourceLoader\FileModule\getPackageFiles(), and MediaWiki\ResourceLoader\Module\getVersionHash().
MediaWiki\ResourceLoader\Context::getImage | ( | ) |
Definition at line 354 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::getImageObj | ( | ) |
If this is a request for an image, get the Image object.
Definition at line 378 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::getLanguage | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 209 of file Context.php.
References getRequest().
Referenced by MediaWiki\ResourceLoader\SkinModule\getDefinitionSummary(), MediaWiki\ResourceLoader\SkinModule\getLessVars(), MediaWiki\ResourceLoader\Module\getMessageBlob(), MediaWiki\ResourceLoader\Image\getPath(), MediaWiki\ResourceLoader\Image\getUrl(), MediaWiki\ResourceLoader\Module\getVary(), and MediaWiki\ResourceLoader\ResourceLoader\preloadModuleInfo().
MediaWiki\ResourceLoader\Context::getLogger | ( | ) |
Definition at line 201 of file Context.php.
MediaWiki\ResourceLoader\Context::getModules | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 205 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::getOnly | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 326 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Module\buildContent(), MediaWiki\ResourceLoader\StartUpModule\getScript(), MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::getRaw | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 339 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse().
MediaWiki\ResourceLoader\Context::getReqBase | ( | ) |
Get the request base parameters, omitting any defaults.
Definition at line 472 of file Context.php.
Referenced by MediaWiki\ResourceLoader\StartUpModule\getScript().
MediaWiki\ResourceLoader\Context::getRequest | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 191 of file Context.php.
Referenced by MediaWiki\ResourceLoader\StartUpModule\getScript(), and MediaWiki\ResourceLoader\ResourceLoader\tryRespondNotModified().
MediaWiki\ResourceLoader\Context::getResourceLoader | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 187 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ClientHtml\__construct(), MediaWiki\ResourceLoader\FileModule\compileLessString(), MediaWiki\ResourceLoader\Image\getImageData(), MediaWiki\ResourceLoader\Module\getMessageBlob(), MediaWiki\ResourceLoader\FileModule\getScriptURLsForDebug(), MediaWiki\ResourceLoader\Module\getScriptURLsForDebug(), MediaWiki\ResourceLoader\Module\getStyleURLsForDebug(), MediaWiki\ResourceLoader\Image\getUrl(), MediaWiki\ResourceLoader\ClientHtml\makeLoad(), and MediaWiki\ResourceLoader\WikiModule\preloadTitleInfo().
MediaWiki\ResourceLoader\Context::getSkin | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 242 of file Context.php.
Referenced by MediaWiki\ResourceLoader\FileModule\compileLessString(), MediaWiki\ResourceLoader\SiteModule\getPages(), MediaWiki\ResourceLoader\SiteStylesModule\getPages(), MediaWiki\ResourceLoader\UserModule\getPages(), MediaWiki\ResourceLoader\UserStylesModule\getPages(), MediaWiki\ResourceLoader\FileModule\getStyleFiles(), MediaWiki\ResourceLoader\Image\getUrl(), and MediaWiki\ResourceLoader\Module\getVary().
MediaWiki\ResourceLoader\Context::getUser | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 249 of file Context.php.
MediaWiki\ResourceLoader\Context::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.
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 282 of file Context.php.
References getUser().
Referenced by MediaWiki\ResourceLoader\UserModule\getPages(), and MediaWiki\ResourceLoader\UserStylesModule\getPages().
MediaWiki\ResourceLoader\Context::getUserObj | ( | ) |
Get the possibly-cached User object for the specified username.
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 304 of file Context.php.
References getUser().
Referenced by MediaWiki\ResourceLoader\UserOptionsModule\getScript().
MediaWiki\ResourceLoader\Context::getVariant | ( | ) |
Definition at line 361 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Image\getImageData().
MediaWiki\ResourceLoader\Context::getVersion | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 335 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::isSourceMap | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 347 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::msg | ( | $key, | |
$params ) |
Get a Message object with context set.
See wfMessage for parameters.
string | string[] | MessageSpecifier | $key | Message key, or array of keys, or a MessageSpecifier. |
mixed | ...$params |
Implements MessageLocalizer.
Definition at line 262 of file Context.php.
|
static |
Return a dummy Context object suitable for passing into things that don't "really" need a context.
Use cases:
Definition at line 175 of file Context.php.
MediaWiki\ResourceLoader\Context::shouldIncludeMessages | ( | ) |
Definition at line 431 of file Context.php.
MediaWiki\ResourceLoader\Context::shouldIncludeScripts | ( | ) |
Definition at line 423 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::shouldIncludeStyles | ( | ) |
Definition at line 427 of file Context.php.
|
protected |
Definition at line 69 of file Context.php.
|
protected |
Definition at line 92 of file Context.php.
|
protected |
Definition at line 89 of file Context.php.
|
protected |
Definition at line 94 of file Context.php.
|
protected |
Definition at line 85 of file Context.php.
|
protected |
Definition at line 100 of file Context.php.
|
protected |
Definition at line 67 of file Context.php.
|
protected |
Definition at line 61 of file Context.php.
|
protected |
Definition at line 75 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 77 of file Context.php.
|
protected |
Definition at line 81 of file Context.php.
|
protected |
Definition at line 59 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 57 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 65 of file Context.php.
|
protected |
Definition at line 83 of file Context.php.
|
protected |
Definition at line 71 of file Context.php.
|
protected |
Definition at line 98 of file Context.php.
|
protected |
Definition at line 96 of file Context.php.
|
protected |
Definition at line 87 of file Context.php.
|
protected |
Definition at line 79 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEBUG_LEGACY = 1 |
Definition at line 52 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\debugFromString().
const MediaWiki\ResourceLoader\Context::DEBUG_MAIN = 2 |
Definition at line 54 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEBUG_OFF = 0 |
Definition at line 50 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEFAULT_LANG = 'qqx' |
Definition at line 46 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEFAULT_SKIN = 'fallback' |
Definition at line 47 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().