MediaWiki master
MediaWiki\Context\DerivativeContext Class Reference

An IContextSource implementation which will inherit context from another source but allow individual pieces of context to be changed locally eg: A ContextSource that can inherit from the main RequestContext but have a different Title instance set on it. More...

Inherits MediaWiki\Context\ContextSource, and MediaWiki\Context\MutableContext.

Collaboration diagram for MediaWiki\Context\DerivativeContext:

Public Member Functions

 __construct (IContextSource $context)
 
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage().
 
 getActionName ()
 Get the action name for the current web request.
 
 getAuthority ()
 
 getConfig ()
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ( $key,... $params)
 Get a message using the current context.
 
 setActionName (string $action)
 
 setAuthority (Authority $authority)
 
 setConfig (Config $config)
 
 setLanguage ( $language)
 
 setOutput (OutputPage $output)
 
 setRequest (WebRequest $request)
 
 setSkin (Skin $skin)
 
 setTitle (Title $title)
 
 setUser (User $user)
 
 setWikiPage (WikiPage $wikiPage)
 
- Public Member Functions inherited from MediaWiki\Context\ContextSource
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID.
 
 getContext ()
 Get the base IContextSource object.
 
 getCsrfTokenSet ()
 Get a repository to obtain and match CSRF tokens.
 
 getLanguageCode ()
 
 setContext (IContextSource $context)
 

Detailed Description

An IContextSource implementation which will inherit context from another source but allow individual pieces of context to be changed locally eg: A ContextSource that can inherit from the main RequestContext but have a different Title instance set on it.

Stability: newable
Since
1.19

Definition at line 47 of file DerivativeContext.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Context\DerivativeContext::__construct ( IContextSource $context)
Stability: stable
to call
Parameters
IContextSource$contextContext to inherit from

Definition at line 107 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\setContext().

Member Function Documentation

◆ canUseWikiPage()

MediaWiki\Context\DerivativeContext::canUseWikiPage ( )

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.

Since
1.19
Returns
bool

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 169 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext().

◆ getActionName()

MediaWiki\Context\DerivativeContext::getActionName ( )

Get the action name for the current web request.

Since
1.38
Returns
string Action

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 225 of file DerivativeContext.php.

◆ getAuthority()

MediaWiki\Context\DerivativeContext::getAuthority ( )
Since
1.36
Returns
Authority

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 282 of file DerivativeContext.php.

◆ getConfig()

MediaWiki\Context\DerivativeContext::getConfig ( )
Returns
Config

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 121 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext().

◆ getLanguage()

MediaWiki\Context\DerivativeContext::getLanguage ( )
Returns
Language
Since
1.19

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 305 of file DerivativeContext.php.

◆ getOutput()

MediaWiki\Context\DerivativeContext::getOutput ( )
Returns
OutputPage

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 247 of file DerivativeContext.php.

◆ getRequest()

MediaWiki\Context\DerivativeContext::getRequest ( )
Returns
WebRequest

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 142 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext().

◆ getSkin()

MediaWiki\Context\DerivativeContext::getSkin ( )
Returns
Skin

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 320 of file DerivativeContext.php.

◆ getTiming()

MediaWiki\Context\DerivativeContext::getTiming ( )
Returns
Timing

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 128 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext().

◆ getTitle()

MediaWiki\Context\DerivativeContext::getTitle ( )
Returns
Title|null

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 157 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext().

◆ getUser()

MediaWiki\Context\DerivativeContext::getUser ( )
Returns
User

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 262 of file DerivativeContext.php.

◆ getWikiPage()

MediaWiki\Context\DerivativeContext::getWikiPage ( )

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.

Since
1.19
Returns
WikiPage

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 203 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\getContext(), and MediaWiki\MediaWikiServices\getInstance().

◆ msg()

MediaWiki\Context\DerivativeContext::msg ( $key,
$params )

Get a message using the current context.

This can't just inherit from ContextSource, since then it would set only the original context, and not take into account any changes.

Parameters
string | string[] | MessageSpecifier$keyMessage key, or array of keys, or a MessageSpecifier.
mixed...$params
Returns
Message

Reimplemented from MediaWiki\Context\ContextSource.

Definition at line 336 of file DerivativeContext.php.

References $params, and wfMessage().

◆ setActionName()

MediaWiki\Context\DerivativeContext::setActionName ( string $action)
Since
1.38
Parameters
string$action

Implements MediaWiki\Context\MutableContext.

Definition at line 215 of file DerivativeContext.php.

◆ setAuthority()

MediaWiki\Context\DerivativeContext::setAuthority ( Authority $authority)
Stability: unstable
Parameters
Authority$authority

Implements MediaWiki\Context\MutableContext.

Definition at line 272 of file DerivativeContext.php.

◆ setConfig()

MediaWiki\Context\DerivativeContext::setConfig ( Config $config)
Parameters
Config$config

Implements MediaWiki\Context\MutableContext.

Definition at line 114 of file DerivativeContext.php.

◆ setLanguage()

MediaWiki\Context\DerivativeContext::setLanguage ( $language)
Parameters
Language | string$languageLanguage instance or language code
Since
1.19

Implements MediaWiki\Context\MutableContext.

Definition at line 290 of file DerivativeContext.php.

◆ setOutput()

MediaWiki\Context\DerivativeContext::setOutput ( OutputPage $output)
Parameters
OutputPage$output

Implements MediaWiki\Context\MutableContext.

Definition at line 240 of file DerivativeContext.php.

◆ setRequest()

MediaWiki\Context\DerivativeContext::setRequest ( WebRequest $request)
Parameters
WebRequest$request

Implements MediaWiki\Context\MutableContext.

Definition at line 135 of file DerivativeContext.php.

◆ setSkin()

MediaWiki\Context\DerivativeContext::setSkin ( Skin $skin)
Parameters
Skin$skin

Implements MediaWiki\Context\MutableContext.

Definition at line 312 of file DerivativeContext.php.

References MediaWiki\Context\ContextSource\setContext().

◆ setTitle()

MediaWiki\Context\DerivativeContext::setTitle ( Title $title)
Parameters
Title$title

Implements MediaWiki\Context\MutableContext.

Definition at line 149 of file DerivativeContext.php.

Referenced by MediaWiki\Context\DerivativeContext\setWikiPage().

◆ setUser()

MediaWiki\Context\DerivativeContext::setUser ( User $user)
Parameters
User$user

Implements MediaWiki\Context\MutableContext.

Definition at line 254 of file DerivativeContext.php.

◆ setWikiPage()

MediaWiki\Context\DerivativeContext::setWikiPage ( WikiPage $wikiPage)
Since
1.19
Parameters
WikiPage$wikiPage

Implements MediaWiki\Context\MutableContext.

Definition at line 185 of file DerivativeContext.php.

References WikiPage\getTitle(), and MediaWiki\Context\DerivativeContext\setTitle().


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