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 46 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 109 of file Context.php.
References MediaWiki\ResourceLoader\Context\$modules, MediaWiki\ResourceLoader\Context\$request, MediaWiki\ResourceLoader\Context\$resourceLoader, MediaWiki\ResourceLoader\Context\$skin, 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 153 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 499 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 421 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 321 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.
Referenced by MediaWiki\ResourceLoader\FileModule\getFlip(), MediaWiki\ResourceLoader\Module\getFlip(), and MediaWiki\ResourceLoader\Image\getPath().
MediaWiki\ResourceLoader\Context::getFormat | ( | ) |
Definition at line 370 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 448 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Module\getModuleContent(), MediaWiki\ResourceLoader\FileModule\getPackageFiles(), and MediaWiki\ResourceLoader\Module\getVersionHash().
MediaWiki\ResourceLoader\Context::getImage | ( | ) |
Definition at line 356 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 380 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 210 of file Context.php.
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 202 of file Context.php.
MediaWiki\ResourceLoader\Context::getModules | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 206 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::getOnly | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 328 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 341 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 474 of file Context.php.
Referenced by MediaWiki\ResourceLoader\StartUpModule\getScript().
MediaWiki\ResourceLoader\Context::getRequest | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 192 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 188 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ClientHtml\__construct(), MediaWiki\ResourceLoader\FileModule\compileLessString(), MediaWiki\ResourceLoader\Module\getFileDependencies(), 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(), MediaWiki\ResourceLoader\WikiModule\preloadTitleInfo(), and MediaWiki\ResourceLoader\Module\saveFileDependencies().
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 284 of file Context.php.
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 306 of file Context.php.
Referenced by MediaWiki\ResourceLoader\UserOptionsModule\getScript().
MediaWiki\ResourceLoader\Context::getVariant | ( | ) |
Definition at line 363 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Image\getImageData().
MediaWiki\ResourceLoader\Context::getVersion | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 337 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::isSourceMap | ( | ) |
Reimplemented in MediaWiki\ResourceLoader\DerivativeContext.
Definition at line 349 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. @phpcs:ignore Generic.Files.LineLength |
MessageParam|MessageSpecifier|string|int|float|list<MessageParam|MessageSpecifier|string|int|float> | ...$params See Message::params() |
Implements MessageLocalizer.
Definition at line 264 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 176 of file Context.php.
MediaWiki\ResourceLoader\Context::shouldIncludeMessages | ( | ) |
Definition at line 433 of file Context.php.
MediaWiki\ResourceLoader\Context::shouldIncludeScripts | ( | ) |
Definition at line 425 of file Context.php.
Referenced by MediaWiki\ResourceLoader\ResourceLoader\makeModuleResponse(), and MediaWiki\ResourceLoader\ResourceLoader\respond().
MediaWiki\ResourceLoader\Context::shouldIncludeStyles | ( | ) |
Definition at line 429 of file Context.php.
|
protected |
Definition at line 70 of file Context.php.
|
protected |
Definition at line 93 of file Context.php.
|
protected |
Definition at line 90 of file Context.php.
|
protected |
Definition at line 95 of file Context.php.
|
protected |
Definition at line 86 of file Context.php.
|
protected |
Definition at line 101 of file Context.php.
|
protected |
Definition at line 68 of file Context.php.
|
protected |
Definition at line 62 of file Context.php.
|
protected |
Definition at line 76 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 78 of file Context.php.
|
protected |
Definition at line 82 of file Context.php.
|
protected |
Definition at line 60 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 58 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 66 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().
|
protected |
Definition at line 84 of file Context.php.
|
protected |
Definition at line 72 of file Context.php.
|
protected |
Definition at line 99 of file Context.php.
|
protected |
Definition at line 97 of file Context.php.
|
protected |
Definition at line 88 of file Context.php.
|
protected |
Definition at line 80 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEBUG_LEGACY = 1 |
Definition at line 53 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\debugFromString().
const MediaWiki\ResourceLoader\Context::DEBUG_MAIN = 2 |
Definition at line 55 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEBUG_OFF = 0 |
Definition at line 51 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEFAULT_LANG = 'qqx' |
Definition at line 47 of file Context.php.
const MediaWiki\ResourceLoader\Context::DEFAULT_SKIN = 'fallback' |
Definition at line 48 of file Context.php.
Referenced by MediaWiki\ResourceLoader\Context\__construct().