MediaWiki  1.32.5
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(). More...
 
 getConfig ()
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ( $key)
 Get a message using the current context. More...
 
 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. More...
 
 getContext ()
 Get the base IContextSource object. More...
 
 setContext (IContextSource $context)
 

Private Attributes

Config $config
 
Language $lang
 
OutputPage $output
 
WebRequest $request
 
Skin $skin
 
Timing $timing
 
Title $title
 
User $user
 
WikiPage $wikipage
 

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.

Since
1.19

Definition at line 30 of file DerivativeContext.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 79 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 165 of file DerivativeContext.php.

References ContextSource\getContext(), and title.

◆ getConfig()

DerivativeContext::getConfig ( )
Returns
Config

Reimplemented from ContextSource.

Definition at line 93 of file DerivativeContext.php.

References $config, and ContextSource\getContext().

◆ getLanguage()

DerivativeContext::getLanguage ( )
Returns
Language
Since
1.19

Reimplemented from ContextSource.

Definition at line 257 of file DerivativeContext.php.

References $lang, and ContextSource\getContext().

◆ getOutput()

DerivativeContext::getOutput ( )
Returns
OutputPage

Reimplemented from ContextSource.

Definition at line 210 of file DerivativeContext.php.

References $output, ContextSource\getContext(), and captcha-old\output.

◆ getRequest()

DerivativeContext::getRequest ( )
Returns
WebRequest

Reimplemented from ContextSource.

Definition at line 131 of file DerivativeContext.php.

References $request, ContextSource\getContext(), and request.

◆ getSkin()

DerivativeContext::getSkin ( )
Returns
Skin

Reimplemented from ContextSource.

Definition at line 276 of file DerivativeContext.php.

References $skin, and ContextSource\getContext().

◆ getStats()

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

Reimplemented from ContextSource.

Definition at line 106 of file DerivativeContext.php.

◆ getTiming()

DerivativeContext::getTiming ( )
Returns
Timing

Reimplemented from ContextSource.

Definition at line 113 of file DerivativeContext.php.

References $timing, and ContextSource\getContext().

◆ getTitle()

DerivativeContext::getTitle ( )
Returns
Title|null

Reimplemented from ContextSource.

Definition at line 149 of file DerivativeContext.php.

References $title, ContextSource\getContext(), and title.

◆ getUser()

DerivativeContext::getUser ( )
Returns
User

Reimplemented from ContextSource.

Definition at line 228 of file DerivativeContext.php.

References $user, ContextSource\getContext(), and user.

◆ 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 192 of file DerivativeContext.php.

References $wikipage, and ContextSource\getContext().

◆ msg()

DerivativeContext::msg (   $key)

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$args,...Arguments to wfMessage
Returns
Message

Reimplemented from ContextSource.

Definition at line 296 of file DerivativeContext.php.

References $args, and wfMessage().

◆ setConfig()

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

Implements MutableContext.

Definition at line 86 of file DerivativeContext.php.

References $config.

◆ setLanguage()

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

Implements MutableContext.

Definition at line 241 of file DerivativeContext.php.

References Language\factory(), and RequestContext\sanitizeLangCode().

◆ setOutput()

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

Implements MutableContext.

Definition at line 203 of file DerivativeContext.php.

References $output, and captcha-old\output.

◆ setRequest()

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

Implements MutableContext.

Definition at line 124 of file DerivativeContext.php.

References $request, and request.

◆ setSkin()

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

Implements MutableContext.

Definition at line 268 of file DerivativeContext.php.

References $skin, and ContextSource\setContext().

◆ setTitle()

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

Implements MutableContext.

Definition at line 142 of file DerivativeContext.php.

References $title, and title.

◆ setUser()

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

Implements MutableContext.

Definition at line 221 of file DerivativeContext.php.

References $user, and user.

Referenced by WatchActionTest\testShowUserLoggedInNoException(), and WatchActionTest\testShowUserNotLoggedIn().

◆ setWikiPage()

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

Implements MutableContext.

Definition at line 179 of file DerivativeContext.php.

Member Data Documentation

◆ $config

Config DerivativeContext::$config
private

Definition at line 69 of file DerivativeContext.php.

Referenced by getConfig(), and setConfig().

◆ $lang

Language DerivativeContext::$lang
private

Definition at line 59 of file DerivativeContext.php.

Referenced by getLanguage().

◆ $output

OutputPage DerivativeContext::$output
private

Definition at line 49 of file DerivativeContext.php.

Referenced by getOutput(), and setOutput().

◆ $request

WebRequest DerivativeContext::$request
private

Definition at line 34 of file DerivativeContext.php.

Referenced by getRequest(), and setRequest().

◆ $skin

Skin DerivativeContext::$skin
private

Definition at line 64 of file DerivativeContext.php.

Referenced by getSkin(), and setSkin().

◆ $timing

Timing DerivativeContext::$timing
private

Definition at line 74 of file DerivativeContext.php.

Referenced by getTiming().

◆ $title

Title DerivativeContext::$title
private

Definition at line 39 of file DerivativeContext.php.

Referenced by getTitle(), and setTitle().

◆ $user

User DerivativeContext::$user
private

Definition at line 54 of file DerivativeContext.php.

Referenced by getUser(), and setUser().

◆ $wikipage

WikiPage DerivativeContext::$wikipage
private

Definition at line 44 of file DerivativeContext.php.

Referenced by getWikiPage().


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