MediaWiki  1.30.0
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 ()
 Get the Config object. More...
 
 getLanguage ()
 Get the Language object. More...
 
 getOutput ()
 Get the OutputPage object. More...
 
 getRequest ()
 Get the WebRequest object. More...
 
 getSkin ()
 Get the Skin object. More...
 
 getStats ()
 Get the stats object. More...
 
 getTiming ()
 Get the timing object. More...
 
 getTitle ()
 Get the Title object. More...
 
 getUser ()
 Get the User object. More...
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ( $key)
 Get a message using the current context. More...
 
 setConfig (Config $s)
 Set the SiteConfiguration object. More...
 
 setLanguage ( $l)
 Set the Language object. More...
 
 setOutput (OutputPage $o)
 Set the OutputPage object. More...
 
 setRequest (WebRequest $r)
 Set the WebRequest object. More...
 
 setSkin (Skin $s)
 Set the Skin object. More...
 
 setTitle (Title $t)
 Set the Title object. More...
 
 setUser (User $u)
 Set the User object. More...
 
 setWikiPage (WikiPage $p)
 Set the WikiPage object. More...
 
- 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)
 Set the IContextSource object. More...
 

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References ContextSource\getContext(), and title.

◆ getConfig()

DerivativeContext::getConfig ( )

Get the Config object.

Returns
Config

Reimplemented from ContextSource.

Definition at line 98 of file DerivativeContext.php.

References $config, and ContextSource\getContext().

◆ getLanguage()

DerivativeContext::getLanguage ( )

Get the Language object.

Returns
Language
Since
1.19

Reimplemented from ContextSource.

Definition at line 288 of file DerivativeContext.php.

References $lang, and ContextSource\getContext().

◆ getOutput()

DerivativeContext::getOutput ( )

Get the OutputPage object.

Returns
OutputPage

Reimplemented from ContextSource.

Definition at line 233 of file DerivativeContext.php.

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

◆ getRequest()

DerivativeContext::getRequest ( )

Get the WebRequest object.

Returns
WebRequest

Reimplemented from ContextSource.

Definition at line 144 of file DerivativeContext.php.

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

◆ getSkin()

DerivativeContext::getSkin ( )

Get the Skin object.

Returns
Skin

Reimplemented from ContextSource.

Definition at line 311 of file DerivativeContext.php.

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

◆ getStats()

DerivativeContext::getStats ( )

Get the stats object.

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

Reimplemented from ContextSource.

Definition at line 113 of file DerivativeContext.php.

◆ getTiming()

DerivativeContext::getTiming ( )

Get the timing object.

Returns
Timing

Reimplemented from ContextSource.

Definition at line 122 of file DerivativeContext.php.

References $timing, and ContextSource\getContext().

◆ getTitle()

DerivativeContext::getTitle ( )

Get the Title object.

Returns
Title|null

Reimplemented from ContextSource.

Definition at line 166 of file DerivativeContext.php.

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

◆ getUser()

DerivativeContext::getUser ( )

Get the User object.

Returns
User

Reimplemented from ContextSource.

Definition at line 255 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 211 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 331 of file DerivativeContext.php.

References $args.

◆ setConfig()

DerivativeContext::setConfig ( Config  $s)

Set the SiteConfiguration object.

Parameters
Config$s

Implements MutableContext.

Definition at line 89 of file DerivativeContext.php.

References $s.

◆ setLanguage()

DerivativeContext::setLanguage (   $l)

Set the Language object.

Parameters
Language | string$lLanguage instance or language code
Exceptions
MWException
Since
1.19

Implements MutableContext.

Definition at line 270 of file DerivativeContext.php.

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

◆ setOutput()

DerivativeContext::setOutput ( OutputPage  $o)

Set the OutputPage object.

Parameters
OutputPage$o

Implements MutableContext.

Definition at line 224 of file DerivativeContext.php.

References output().

◆ setRequest()

DerivativeContext::setRequest ( WebRequest  $r)

Set the WebRequest object.

Parameters
WebRequest$r

Implements MutableContext.

Definition at line 135 of file DerivativeContext.php.

References request.

◆ setSkin()

DerivativeContext::setSkin ( Skin  $s)

Set the Skin object.

Parameters
Skin$s

Implements MutableContext.

Definition at line 301 of file DerivativeContext.php.

References $s, ContextSource\setContext(), and skin().

◆ setTitle()

DerivativeContext::setTitle ( Title  $t)

Set the Title object.

Parameters
Title$t

Implements MutableContext.

Definition at line 157 of file DerivativeContext.php.

References $t, and title.

◆ setUser()

DerivativeContext::setUser ( User  $u)

Set the User object.

Parameters
User$u

Implements MutableContext.

Definition at line 246 of file DerivativeContext.php.

References user.

◆ setWikiPage()

DerivativeContext::setWikiPage ( WikiPage  $p)

Set the WikiPage object.

Since
1.19
Parameters
WikiPage$p

Implements MutableContext.

Definition at line 198 of file DerivativeContext.php.

Member Data Documentation

◆ $config

Config DerivativeContext::$config
private

Definition at line 70 of file DerivativeContext.php.

Referenced by getConfig().

◆ $lang

Language DerivativeContext::$lang
private

Definition at line 60 of file DerivativeContext.php.

Referenced by getLanguage().

◆ $output

OutputPage DerivativeContext::$output
private

Definition at line 50 of file DerivativeContext.php.

Referenced by getOutput().

◆ $request

WebRequest DerivativeContext::$request
private

Definition at line 35 of file DerivativeContext.php.

Referenced by getRequest().

◆ $skin

Skin DerivativeContext::$skin
private

Definition at line 65 of file DerivativeContext.php.

Referenced by getSkin().

◆ $timing

Timing DerivativeContext::$timing
private

Definition at line 75 of file DerivativeContext.php.

Referenced by getTiming().

◆ $title

Title DerivativeContext::$title
private

Definition at line 40 of file DerivativeContext.php.

Referenced by getTitle().

◆ $user

User DerivativeContext::$user
private

Definition at line 55 of file DerivativeContext.php.

Referenced by getUser().

◆ $wikipage

WikiPage DerivativeContext::$wikipage
private

Definition at line 45 of file DerivativeContext.php.

Referenced by getWikiPage().


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