MediaWiki REL1_39
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...

Inheritance diagram for DerivativeContext:
Collaboration diagram for 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 ()
 
 getStats ()
 
 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 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.
 
 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 32 of file DerivativeContext.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 92 of file DerivativeContext.php.

References ContextSource\setContext().

Member Function Documentation

◆ canUseWikiPage()

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 ContextSource.

Definition at line 164 of file DerivativeContext.php.

References ContextSource\getContext().

◆ getActionName()

DerivativeContext::getActionName ( )

Get the action name for the current web request.

Since
1.38
Returns
string Action

Reimplemented from ContextSource.

Definition at line 219 of file DerivativeContext.php.

◆ getAuthority()

DerivativeContext::getAuthority ( )
Since
1.36
Returns
Authority

Reimplemented from ContextSource.

Definition at line 268 of file DerivativeContext.php.

◆ getConfig()

DerivativeContext::getConfig ( )
Returns
Config

Reimplemented from ContextSource.

Definition at line 106 of file DerivativeContext.php.

References ContextSource\getContext().

◆ getLanguage()

DerivativeContext::getLanguage ( )
Returns
Language
Since
1.19

Reimplemented from ContextSource.

Definition at line 293 of file DerivativeContext.php.

References getContext().

◆ getOutput()

DerivativeContext::getOutput ( )
Returns
OutputPage

Reimplemented from ContextSource.

Definition at line 233 of file DerivativeContext.php.

References getContext().

◆ getRequest()

DerivativeContext::getRequest ( )
Returns
WebRequest

Reimplemented from ContextSource.

Definition at line 138 of file DerivativeContext.php.

References ContextSource\getContext().

◆ getSkin()

DerivativeContext::getSkin ( )
Returns
Skin

Reimplemented from ContextSource.

Definition at line 308 of file DerivativeContext.php.

References getContext().

◆ getStats()

DerivativeContext::getStats ( )
Deprecated
since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected). Hard deprecated since 1.39.
Returns
IBufferingStatsdDataFactory

Reimplemented from ContextSource.

Definition at line 116 of file DerivativeContext.php.

References wfDeprecated().

◆ getTiming()

DerivativeContext::getTiming ( )
Returns
Timing

Reimplemented from ContextSource.

Definition at line 124 of file DerivativeContext.php.

References ContextSource\getContext().

◆ getTitle()

DerivativeContext::getTitle ( )
Returns
Title|null

Reimplemented from ContextSource.

Definition at line 152 of file DerivativeContext.php.

References ContextSource\getContext().

◆ getUser()

DerivativeContext::getUser ( )
Returns
User

Reimplemented from ContextSource.

Definition at line 248 of file DerivativeContext.php.

References getContext().

◆ getWikiPage()

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 ContextSource.

Definition at line 197 of file DerivativeContext.php.

References ContextSource\getContext().

◆ msg()

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 ContextSource.

Definition at line 324 of file DerivativeContext.php.

References wfMessage().

◆ setActionName()

DerivativeContext::setActionName ( string $action)
Since
1.38
Parameters
string$action

Implements MutableContext.

Definition at line 209 of file DerivativeContext.php.

◆ setAuthority()

DerivativeContext::setAuthority ( Authority $authority)
Stability: unstable
Parameters
Authority$authority

Implements MutableContext.

Definition at line 258 of file DerivativeContext.php.

◆ setConfig()

DerivativeContext::setConfig ( Config $config)
Parameters
Config$config

Implements MutableContext.

Definition at line 99 of file DerivativeContext.php.

◆ setLanguage()

DerivativeContext::setLanguage ( $language)
Parameters
Language | string$languageLanguage instance or language code
Exceptions
MWException
Since
1.19

Implements MutableContext.

Definition at line 277 of file DerivativeContext.php.

◆ setOutput()

DerivativeContext::setOutput ( OutputPage $output)
Parameters
OutputPage$output

Implements MutableContext.

Definition at line 226 of file DerivativeContext.php.

◆ setRequest()

DerivativeContext::setRequest ( WebRequest $request)
Parameters
WebRequest$request

Implements MutableContext.

Definition at line 131 of file DerivativeContext.php.

◆ setSkin()

DerivativeContext::setSkin ( Skin $skin)
Parameters
Skin$skin

Implements MutableContext.

Definition at line 300 of file DerivativeContext.php.

References ContextSource\setContext().

◆ setTitle()

DerivativeContext::setTitle ( Title $title)
Parameters
Title$title

Implements MutableContext.

Definition at line 145 of file DerivativeContext.php.

References $title.

Referenced by setWikiPage().

◆ setUser()

DerivativeContext::setUser ( User $user)
Parameters
User$user

Implements MutableContext.

Definition at line 240 of file DerivativeContext.php.

◆ setWikiPage()

DerivativeContext::setWikiPage ( WikiPage $wikiPage)
Since
1.19
Parameters
WikiPage$wikiPage

Implements MutableContext.

Definition at line 180 of file DerivativeContext.php.

References WikiPage\getTitle(), and setTitle().


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