MediaWiki
REL1_23
|
Group all the pieces relevant to the context of a request into one instance. More...
Public Member Functions | |
canUseWikiPage () | |
Check whether a WikiPage object can be get with getWikiPage(). | |
exportSession () | |
Export the resolved user IP, HTTP headers, user ID, and session ID. | |
getConfig () | |
Get the Config object. | |
getLang () | |
getLanguage () | |
Get the Language object. | |
getOutput () | |
Get the OutputPage object. | |
getRequest () | |
Get the WebRequest object. | |
getSkin () | |
Get the Skin object. | |
getTitle () | |
Get the Title object. | |
getUser () | |
Get the User object. | |
getWikiPage () | |
Get the WikiPage object. | |
msg () | |
Helpful methods. | |
setConfig (Config $c) | |
Set the Config object. | |
setLang ($l) | |
Set the Language object. | |
setLanguage ($l) | |
Set the Language object. | |
setOutput (OutputPage $o) | |
setRequest (WebRequest $r) | |
Set the WebRequest object. | |
setSkin (Skin $s) | |
Set the Skin object. | |
setTitle ($t) | |
Set the Title object. | |
setUser (User $u) | |
Set the User object. | |
setWikiPage (WikiPage $p) | |
Set the WikiPage object. | |
Static Public Member Functions | |
static | getMain () |
Static methods. | |
static | importScopedSession (array $params) |
Import the resolved user IP, HTTP headers, user ID, and session ID. | |
static | newExtraneousContext (Title $title, $request=array()) |
Create a new extraneous context. | |
static | sanitizeLangCode ($code) |
Accepts a language code and ensures it's sane. | |
Private Attributes | |
Config | $config |
Language | $lang |
OutputPage | $output |
WebRequest | $request |
Skin | $skin |
Title | $title |
User | $user |
WikiPage | $wikipage |
Group all the pieces relevant to the context of a request into one instance.
Definition at line 30 of file RequestContext.php.
Check whether a WikiPage object can be get with getWikiPage().
Callers should expect that an exception is thrown from getWikiPage() if this method returns false.
Implements IContextSource.
Definition at line 147 of file RequestContext.php.
Export the resolved user IP, HTTP headers, user ID, and session ID.
The result will be reasonably sized to allow for serialization.
Implements IContextSource.
Definition at line 436 of file RequestContext.php.
References array(), getRequest(), and getUser().
Get the Config object.
Implements IContextSource.
Definition at line 77 of file RequestContext.php.
Implements IContextSource.
Definition at line 297 of file RequestContext.php.
Get the Language object.
Initialization of user or request objects can depend on this.
Implements IContextSource.
Definition at line 310 of file RequestContext.php.
References $e, $request, $user, $wgContLang, array(), Language\factory(), User\getOption(), getRequest(), getUser(), WebRequest\getVal(), global, sanitizeLangCode(), wfDebugLog(), and wfRunHooks().
Referenced by UploadFromUrlTestSuite\setUp().
static RequestContext::getMain | ( | ) | [static] |
Static methods.
Get the RequestContext object associated with the main request
Definition at line 420 of file RequestContext.php.
Referenced by UserBlockedError\__construct(), LogFormatter\__construct(), StubUserLang\_newObject(), Linker\buildRollbackLink(), Title\checkUserBlock(), FixDoubleRedirects\execute(), EditCLI\execute(), FeedUtils\formatDiffRow(), Linker\generateRollback(), SpecialPageFactory\getUsablePages(), WikitextContent\isCountable(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), MediaWikiLangTestCase\setUp(), MWTimestampTest\setUp(), SpecialListFilesTest\testFormatValuesThrowException(), RequestContextTest\testImportScopedSession(), and wfStreamThumb().
Get the OutputPage object.
Implements IContextSource.
Definition at line 212 of file RequestContext.php.
Get the WebRequest object.
Implements IContextSource.
Definition at line 101 of file RequestContext.php.
Referenced by exportSession(), and getLanguage().
Get the Skin object.
Implements IContextSource.
Definition at line 360 of file RequestContext.php.
Get the Title object.
Implements IContextSource.
Definition at line 130 of file RequestContext.php.
Get the User object.
Implements IContextSource.
Definition at line 234 of file RequestContext.php.
Referenced by exportSession(), and getLanguage().
Get the WikiPage object.
May throw an exception if there's no Title object set or the Title object belongs to a special namespace that doesn't have WikiPage, so use first canUseWikiPage() to check whether this method can be called safely.
MWException |
Implements IContextSource.
Definition at line 188 of file RequestContext.php.
static RequestContext::importScopedSession | ( | array $ | params | ) | [static] |
Import the resolved user IP, HTTP headers, user ID, and session ID.
This sets the current session and sets $wgUser and $wgRequest. Once the return value falls out of scope, the old context is restored. This function can only be called within CLI mode scripts.
This will setup the session from the given ID. This is useful when background scripts inherit context when acting on behalf of a user.
array | $params | Result of RequestContext::exportSession() |
MWException |
Definition at line 461 of file RequestContext.php.
Referenced by AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), and RequestContextTest\testImportScopedSession().
Helpful methods.
Get a Message object with context set Parameters are the same as wfMessage()
Implements IContextSource.
Definition at line 407 of file RequestContext.php.
static RequestContext::newExtraneousContext | ( | Title $ | title, |
$ | request = array() |
||
) | [static] |
Create a new extraneous context.
The context is filled with information external to the current session.
Title | $title | Title to use for the extraneous request |
WebRequest | array | $request | A WebRequest or data to use for a FauxRequest |
Definition at line 535 of file RequestContext.php.
Referenced by RecentChangeTest\__construct(), and Title\moveToInternal().
static RequestContext::sanitizeLangCode | ( | $ | code | ) | [static] |
Accepts a language code and ensures it's sane.
Outputs a cleaned up language code and replaces with $wgLanguageCode if not sane.
string | $code | Language code |
Definition at line 248 of file RequestContext.php.
Referenced by ResourceLoaderContext\getLanguage(), getLanguage(), DerivativeContext\setLanguage(), and setLanguage().
RequestContext::setConfig | ( | Config $ | c | ) |
RequestContext::setLang | ( | $ | l | ) |
Set the Language object.
Definition at line 269 of file RequestContext.php.
RequestContext::setLanguage | ( | $ | l | ) |
Set the Language object.
MWException |
Definition at line 281 of file RequestContext.php.
References Language\factory(), and sanitizeLangCode().
$o | OutputPage |
Definition at line 203 of file RequestContext.php.
Set the WebRequest object.
WebRequest | $r |
Definition at line 92 of file RequestContext.php.
Referenced by ApiEditPage\execute().
RequestContext::setSkin | ( | Skin $ | s | ) |
RequestContext::setTitle | ( | $ | t | ) |
Set the Title object.
Title | $t |
MWException |
Definition at line 116 of file RequestContext.php.
Referenced by PreferencesTest\__construct(), and RebuildFileCache\execute().
RequestContext::setUser | ( | User $ | u | ) |
Set the User object.
User | $u |
Definition at line 225 of file RequestContext.php.
Referenced by SpecialSearchTest\testProfileAndNamespaceLoading().
Set the WikiPage object.
WikiPage | $p |
Definition at line 168 of file RequestContext.php.
Config RequestContext::$config [private] |
Definition at line 61 of file RequestContext.php.
Language RequestContext::$lang [private] |
Definition at line 53 of file RequestContext.php.
OutputPage RequestContext::$output [private] |
Definition at line 45 of file RequestContext.php.
WebRequest RequestContext::$request [private] |
Definition at line 33 of file RequestContext.php.
Referenced by getLanguage().
Definition at line 57 of file RequestContext.php.
Definition at line 37 of file RequestContext.php.
Definition at line 49 of file RequestContext.php.
Referenced by getLanguage(), and ApiTestContext\newTestContext().
WikiPage RequestContext::$wikipage [private] |
Definition at line 41 of file RequestContext.php.