MediaWiki REL1_28
IContextSource Interface Reference

Interface for objects which can provide a MediaWiki context on request. More...

Inheritance diagram for IContextSource:

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 site configuration.
 
 getLanguage ()
 Get the Language object.
 
 getOutput ()
 Get the OutputPage object.
 
 getRequest ()
 Get the WebRequest object.
 
 getSkin ()
 Get the Skin object.
 
 getStats ()
 Get the stats object.
 
 getTiming ()
 Get the timing object.
 
 getTitle ()
 Get the Title object.
 
 getUser ()
 Get the User object.
 
 getWikiPage ()
 Get the WikiPage object.
 
 msg ()
 Get a Message object with context set.
 

Detailed Description

Interface for objects which can provide a MediaWiki context on request.

Context objects contain request-dependent objects that manage the core web request/response logic for essentially all requests to MediaWiki. The contained objects include: a) Key objects that depend (for construction/loading) on the HTTP request b) Key objects used for response building and PHP session state control c) Performance metric deltas accumulated from request execution d) The site configuration object All of the objects are useful for the vast majority of MediaWiki requests. The site configuration object is included on grounds of extreme utility, even though it should not actually depend on the web request.

More specifically, the scope of the context includes: a) Objects that represent the HTTP request/response and PHP session state b) Object representing the MediaWiki user (as determined by the HTTP request) c) Primary MediaWiki output builder objects (OutputPage, user skin object) d) The language object for the user/request e) The title and wiki page objects requested via URL (if any) f) Performance metric deltas accumulated from request execution g) The site configuration object

This class is not intended as a service-locator nor a service singleton. Objects that only depend on site configuration do not belong here (aside from Config itself). Objects that represent persistent data stores do not belong here either. Session state changes should only be propagated on shutdown by separate persistence handler objects, for example.

Definition at line 55 of file IContextSource.php.

Member Function Documentation

◆ canUseWikiPage()

IContextSource::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

Implemented in ContextSource, DerivativeContext, and RequestContext.

◆ exportSession()

IContextSource::exportSession ( )

Export the resolved user IP, HTTP headers, user ID, and session ID.

The result will be reasonably sized to allow for serialization.

Returns
array
Since
1.21

Implemented in ContextSource, and RequestContext.

◆ getConfig()

IContextSource::getConfig ( )

◆ getLanguage()

◆ getOutput()

IContextSource::getOutput ( )

◆ getRequest()

IContextSource::getRequest ( )

Get the WebRequest object.

Returns
WebRequest

Implemented in ContextSource, DerivativeContext, and RequestContext.

Referenced by ChangesList\newFromContext().

◆ getSkin()

IContextSource::getSkin ( )

◆ getStats()

IContextSource::getStats ( )

Get the stats object.

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

Implemented in ContextSource, DerivativeContext, and RequestContext.

◆ getTiming()

IContextSource::getTiming ( )

Get the timing object.

Since
1.27
Returns
Timing

Implemented in ContextSource, DerivativeContext, and RequestContext.

◆ getTitle()

IContextSource::getTitle ( )

◆ getUser()

IContextSource::getUser ( )

Get the User object.

Returns
User

Implemented in ContextSource, DerivativeContext, and RequestContext.

Referenced by ChangesList\newFromContext().

◆ getWikiPage()

IContextSource::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

Implemented in ContextSource, DerivativeContext, and RequestContext.

◆ msg()

IContextSource::msg ( )

Get a Message object with context set.

See wfMessage for parameters.

Parameters
mixed...
Returns
Message

Implemented in ContextSource, DerivativeContext, and RequestContext.

Referenced by ApiFormatBase\closePrinter(), ApiHelp\getHelp(), ApiHelp\getHelpInternal(), ChangesList\showCharacterDifference(), and LogEventsList\showLogExtract().


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