MediaWiki REL1_35
ContextSource.php
Go to the documentation of this file.
1<?php
22
30abstract class ContextSource implements IContextSource {
34 private $context;
35
42 public function getContext() {
43 if ( $this->context === null ) {
44 $class = static::class;
45 wfDebug( __METHOD__ . " ($class): called and \$context is null. " .
46 "Using RequestContext::getMain() for sanity" );
47 $this->context = RequestContext::getMain();
48 }
49
50 return $this->context;
51 }
52
58 public function setContext( IContextSource $context ) {
59 $this->context = $context;
60 }
61
67 public function getConfig() {
68 return $this->getContext()->getConfig();
69 }
70
76 public function getRequest() {
77 return $this->getContext()->getRequest();
78 }
79
85 public function getTitle() {
86 return $this->getContext()->getTitle();
87 }
88
98 public function canUseWikiPage() {
99 return $this->getContext()->canUseWikiPage();
100 }
101
112 public function getWikiPage() {
113 return $this->getContext()->getWikiPage();
114 }
115
121 public function getOutput() {
122 return $this->getContext()->getOutput();
123 }
124
131 public function getUser() {
132 return $this->getContext()->getUser();
133 }
134
140 public function getLanguage() {
141 return $this->getContext()->getLanguage();
142 }
143
149 public function getSkin() {
150 return $this->getContext()->getSkin();
151 }
152
158 public function getTiming() {
159 return $this->getContext()->getTiming();
160 }
161
169 public function getStats() {
170 return MediaWikiServices::getInstance()->getStatsdDataFactory();
171 }
172
184 public function msg( $key, ...$params ) {
185 return $this->getContext()->msg( $key, ...$params );
186 }
187
196 public function exportSession() {
197 return $this->getContext()->exportSession();
198 }
199}
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
getUser()
Stable to override.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
canUseWikiPage()
Check whether a WikiPage object can be get with getWikiPage().
exportSession()
Export the resolved user IP, HTTP headers, user ID, and session ID.
IContextSource $context
getWikiPage()
Get the WikiPage object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
MediaWikiServices is the service locator for the application scope of MediaWiki.
Interface for objects which can provide a MediaWiki context on request.