MediaWiki REL1_32
DerivativeContext.php
Go to the documentation of this file.
1<?php
22
34 private $request;
35
39 private $title;
40
44 private $wikipage;
45
49 private $output;
50
54 private $user;
55
59 private $lang;
60
64 private $skin;
65
69 private $config;
70
74 private $timing;
75
79 public function __construct( IContextSource $context ) {
80 $this->setContext( $context );
81 }
82
86 public function setConfig( Config $config ) {
87 $this->config = $config;
88 }
89
93 public function getConfig() {
94 if ( !is_null( $this->config ) ) {
95 return $this->config;
96 } else {
97 return $this->getContext()->getConfig();
98 }
99 }
100
106 public function getStats() {
107 return MediaWikiServices::getInstance()->getStatsdDataFactory();
108 }
109
113 public function getTiming() {
114 if ( !is_null( $this->timing ) ) {
115 return $this->timing;
116 } else {
117 return $this->getContext()->getTiming();
118 }
119 }
120
124 public function setRequest( WebRequest $request ) {
125 $this->request = $request;
126 }
127
131 public function getRequest() {
132 if ( !is_null( $this->request ) ) {
133 return $this->request;
134 } else {
135 return $this->getContext()->getRequest();
136 }
137 }
138
142 public function setTitle( Title $title ) {
143 $this->title = $title;
144 }
145
149 public function getTitle() {
150 if ( !is_null( $this->title ) ) {
151 return $this->title;
152 } else {
153 return $this->getContext()->getTitle();
154 }
155 }
156
165 public function canUseWikiPage() {
166 if ( $this->wikipage !== null ) {
167 return true;
168 } elseif ( $this->title !== null ) {
169 return $this->title->canExist();
170 } else {
171 return $this->getContext()->canUseWikiPage();
172 }
173 }
174
179 public function setWikiPage( WikiPage $wikiPage ) {
180 $this->wikipage = $wikiPage;
181 }
182
192 public function getWikiPage() {
193 if ( !is_null( $this->wikipage ) ) {
194 return $this->wikipage;
195 } else {
196 return $this->getContext()->getWikiPage();
197 }
198 }
199
203 public function setOutput( OutputPage $output ) {
204 $this->output = $output;
205 }
206
210 public function getOutput() {
211 if ( !is_null( $this->output ) ) {
212 return $this->output;
213 } else {
214 return $this->getContext()->getOutput();
215 }
216 }
217
221 public function setUser( User $user ) {
222 $this->user = $user;
223 }
224
228 public function getUser() {
229 if ( !is_null( $this->user ) ) {
230 return $this->user;
231 } else {
232 return $this->getContext()->getUser();
233 }
234 }
235
241 public function setLanguage( $language ) {
242 if ( $language instanceof Language ) {
243 $this->lang = $language;
244 } elseif ( is_string( $language ) ) {
245 $language = RequestContext::sanitizeLangCode( $language );
246 $obj = Language::factory( $language );
247 $this->lang = $obj;
248 } else {
249 throw new MWException( __METHOD__ . " was passed an invalid type of data." );
250 }
251 }
252
257 public function getLanguage() {
258 if ( !is_null( $this->lang ) ) {
259 return $this->lang;
260 } else {
261 return $this->getContext()->getLanguage();
262 }
263 }
264
268 public function setSkin( Skin $skin ) {
269 $this->skin = clone $skin;
270 $this->skin->setContext( $this );
271 }
272
276 public function getSkin() {
277 if ( !is_null( $this->skin ) ) {
278 return $this->skin;
279 } else {
280 return $this->getContext()->getSkin();
281 }
282 }
283
296 public function msg( $key ) {
297 $args = func_get_args();
298
299 // phpcs:ignore MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage
300 return wfMessage( ...$args )->setContext( $this );
301 }
302}
if( $line===false) $args
Definition cdb.php:64
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
IContextSource $context
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
An IContextSource implementation which will inherit context from another source but allow individual ...
setRequest(WebRequest $request)
setWikiPage(WikiPage $wikiPage)
getWikiPage()
Get the WikiPage object.
__construct(IContextSource $context)
setConfig(Config $config)
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
setOutput(OutputPage $output)
msg( $key)
Get a message using the current context.
Internationalisation code.
Definition Language.php:35
MediaWiki exception.
MediaWikiServices is the service locator for the application scope of MediaWiki.
This class should be covered by a general architecture document which does not exist as of January 20...
The main skin class which provides methods and properties for all other skins.
Definition Skin.php:38
An interface to help developers measure the performance of their applications.
Definition Timing.php:45
Represents a title within MediaWiki.
Definition Title.php:39
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition User.php:47
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Class representing a MediaWiki article and history.
Definition WikiPage.php:44
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation use $formDescriptor instead default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
Interface for configuration instances.
Definition Config.php:28
Interface for objects which can provide a MediaWiki context on request.