MediaWiki REL1_30
ContextSource.php
Go to the documentation of this file.
1<?php
21use Liuggio\StatsdClient\Factory\StatsdDataFactory;
23
30abstract class ContextSource implements IContextSource {
34 private $context;
35
41 public function getContext() {
42 if ( $this->context === null ) {
43 $class = static::class;
44 wfDebug( __METHOD__ . " ($class): called and \$context is null. " .
45 "Using RequestContext::getMain() for sanity\n" );
46 $this->context = RequestContext::getMain();
47 }
48
49 return $this->context;
50 }
51
58 public function setContext( IContextSource $context ) {
59 $this->context = $context;
60 }
61
68 public function getConfig() {
69 return $this->getContext()->getConfig();
70 }
71
78 public function getRequest() {
79 return $this->getContext()->getRequest();
80 }
81
88 public function getTitle() {
89 return $this->getContext()->getTitle();
90 }
91
100 public function canUseWikiPage() {
101 return $this->getContext()->canUseWikiPage();
102 }
103
113 public function getWikiPage() {
114 return $this->getContext()->getWikiPage();
115 }
116
123 public function getOutput() {
124 return $this->getContext()->getOutput();
125 }
126
133 public function getUser() {
134 return $this->getContext()->getUser();
135 }
136
143 public function getLanguage() {
144 return $this->getContext()->getLanguage();
145 }
146
153 public function getSkin() {
154 return $this->getContext()->getSkin();
155 }
156
163 public function getTiming() {
164 return $this->getContext()->getTiming();
165 }
166
175 public function getStats() {
176 return MediaWikiServices::getInstance()->getStatsdDataFactory();
177 }
178
189 public function msg( $key /* $args */ ) {
190 $args = func_get_args();
191
192 return call_user_func_array( [ $this->getContext(), 'msg' ], $args );
193 }
194
202 public function exportSession() {
203 return $this->getContext()->exportSession();
204 }
205}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
if( $line===false) $args
Definition cdb.php:63
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
getSkin()
Get the Skin object.
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getStats()
Get the Stats object.
getUser()
Get the User object.
getRequest()
Get the WebRequest object.
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
getConfig()
Get the Config object.
getTitle()
Get the Title object.
getTiming()
Get the Timing object.
getOutput()
Get the OutputPage object.
exportSession()
Export the resolved user IP, HTTP headers, user ID, and session ID.
IContextSource $context
getWikiPage()
Get the WikiPage object.
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
MediaWikiServices is the service locator for the application scope of MediaWiki.
static getMain()
Static methods.
Interface for objects which can provide a MediaWiki context on request.