Merge "Special:BlockList: Update remove/change block links"
[mediawiki.git] / includes / skins / components / SkinComponentRegistryContext.php
blob36305342f987004855e82c3ecad09d31c41598b2
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
19 namespace MediaWiki\Skin;
21 use MediaWiki\Config\Config;
22 use MediaWiki\Context\IContextSource;
23 use MediaWiki\Language\Language;
24 use MediaWiki\Output\OutputPage;
25 use MediaWiki\Title\Title;
26 use MediaWiki\User\User;
27 use MessageLocalizer;
28 use Skin;
29 use WikiPage;
31 /**
32 * @internal for use inside Skin and SkinTemplate classes only
33 * @unstable
35 class SkinComponentRegistryContext implements ComponentRegistryContext {
37 /** @var Skin */
38 private $skin;
40 /** @var MessageLocalizer|null */
41 private $localizer = null;
43 public function __construct( Skin $skin ) {
44 $this->skin = $skin;
47 public function getContextSource(): IContextSource {
48 return $this->skin->getContext();
51 /**
52 * @inheritDoc
54 public function getConfig(): Config {
55 return $this->skin->getConfig();
58 /**
59 * @inheritDoc
61 public function getTitle(): Title {
62 return $this->skin->getTitle() ?? Title::makeTitle( NS_MAIN, 'Foo' );
65 /**
66 * @return Title|null the "relevant" title - see Skin::getRelevantTitle
68 public function getRelevantTitle() {
69 return $this->skin->getRelevantTitle() ?? $this->getTitle();
72 public function getOutput(): OutputPage {
73 return $this->skin->getOutput();
76 /**
77 * @return User
79 public function getUser() {
80 return $this->skin->getUser();
83 /**
84 * @return Language $language
86 public function getLanguage() {
87 return $this->skin->getLanguage();
90 public function getMessageLocalizer(): MessageLocalizer {
91 if ( $this->localizer === null ) {
92 // Cannot call getContext in constructor,
93 // because Skin::class does not have a context yet.
94 // But it is valid to call it now
95 $this->localizer = $this->skin->getContext();
98 return $this->localizer;
102 * @return WikiPage
104 public function getWikiPage() {
105 return $this->skin->getWikiPage();