3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
24 use Liuggio\StatsdClient\Factory\StatsdDataFactory
;
27 * Interface for objects which can provide a MediaWiki context on request
29 * Context objects contain request-dependent objects that manage the core
30 * web request/response logic for essentially all requests to MediaWiki.
31 * The contained objects include:
32 * a) Key objects that depend (for construction/loading) on the HTTP request
33 * b) Key objects used for response building and PHP session state control
34 * c) Performance metric deltas accumulated from request execution
35 * d) The site configuration object
36 * All of the objects are useful for the vast majority of MediaWiki requests.
37 * The site configuration object is included on grounds of extreme
38 * utility, even though it should not actually depend on the web request.
40 * More specifically, the scope of the context includes:
41 * a) Objects that represent the HTTP request/response and PHP session state
42 * b) Object representing the MediaWiki user (as determined by the HTTP request)
43 * c) Primary MediaWiki output builder objects (OutputPage, user skin object)
44 * d) The language object for the user/request
45 * e) The title and wiki page objects requested via URL (if any)
46 * f) Performance metric deltas accumulated from request execution
47 * g) The site configuration object
49 * This class is not intended as a service-locator nor a service singleton.
50 * Objects that only depend on site configuration do not belong here (aside
51 * from Config itself). Objects that represent persistent data stores do not
52 * belong here either. Session state changes should only be propagated on
53 * shutdown by separate persistence handler objects, for example.
55 interface IContextSource
{
57 * Get the WebRequest object
61 public function getRequest();
64 * Get the Title object
68 public function getTitle();
71 * Check whether a WikiPage object can be get with getWikiPage().
72 * Callers should expect that an exception is thrown from getWikiPage()
73 * if this method returns false.
78 public function canUseWikiPage();
81 * Get the WikiPage object.
82 * May throw an exception if there's no Title object set or the Title object
83 * belongs to a special namespace that doesn't have WikiPage, so use first
84 * canUseWikiPage() to check whether this method can be called safely.
89 public function getWikiPage();
92 * Get the OutputPage object
96 public function getOutput();
103 public function getUser();
106 * Get the Language object
111 public function getLanguage();
114 * Get the Skin object
118 public function getSkin();
121 * Get the site configuration
126 public function getConfig();
129 * Get the stats object
131 * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
134 * @return StatsdDataFactory
136 public function getStats();
139 * Get the timing object
144 public function getTiming();
147 * Get a Message object with context set. See wfMessage for parameters.
152 public function msg();
155 * Export the resolved user IP, HTTP headers, user ID, and session ID.
156 * The result will be reasonably sized to allow for serialization.
161 public function exportSession();