Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / includes / context / IContextSource.php
blobccefc72f1b3480e8c08370b152113843965050f8
1 <?php
2 /**
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
18 * @since 1.18
20 * @author Happy-melon
21 * @file
24 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
26 /**
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 {
56 /**
57 * Get the WebRequest object
59 * @return WebRequest
61 public function getRequest();
63 /**
64 * Get the Title object
66 * @return Title|null
68 public function getTitle();
70 /**
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.
75 * @since 1.19
76 * @return bool
78 public function canUseWikiPage();
80 /**
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.
86 * @since 1.19
87 * @return WikiPage
89 public function getWikiPage();
91 /**
92 * Get the OutputPage object
94 * @return OutputPage
96 public function getOutput();
98 /**
99 * Get the User object
101 * @return User
103 public function getUser();
106 * Get the Language object
108 * @return Language
109 * @since 1.19
111 public function getLanguage();
114 * Get the Skin object
116 * @return Skin
118 public function getSkin();
121 * Get the site configuration
123 * @since 1.23
124 * @return Config
126 public function getConfig();
129 * Get the stats object
131 * @deprecated since 1.27 use a StatsdDataFactory from MediaWikiServices (preferably injected)
133 * @since 1.25
134 * @return StatsdDataFactory
136 public function getStats();
139 * Get the timing object
141 * @since 1.27
142 * @return Timing
144 public function getTiming();
147 * Get a Message object with context set. See wfMessage for parameters.
149 * @param mixed ...
150 * @return Message
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.
158 * @return array
159 * @since 1.21
161 public function exportSession();