Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 1 |
SkinComponentRegistryContext | |
0.00% |
0 / 12 |
|
0.00% |
0 / 10 |
132 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContextSource | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getConfig | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getRelevantTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getOutput | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getUser | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLanguage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMessageLocalizer | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getWikiPage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
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. |
7 | * |
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. |
12 | * |
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 |
17 | */ |
18 | |
19 | namespace MediaWiki\Skin; |
20 | |
21 | use MediaWiki\Config\Config; |
22 | use MediaWiki\Context\IContextSource; |
23 | use MediaWiki\Language\Language; |
24 | use MediaWiki\Output\OutputPage; |
25 | use MediaWiki\Page\WikiPage; |
26 | use MediaWiki\Title\Title; |
27 | use MediaWiki\User\User; |
28 | use MessageLocalizer; |
29 | |
30 | /** |
31 | * @internal for use inside Skin and SkinTemplate classes only |
32 | * @unstable |
33 | */ |
34 | class SkinComponentRegistryContext implements ComponentRegistryContext { |
35 | |
36 | /** @var Skin */ |
37 | private $skin; |
38 | |
39 | /** @var MessageLocalizer|null */ |
40 | private $localizer = null; |
41 | |
42 | public function __construct( Skin $skin ) { |
43 | $this->skin = $skin; |
44 | } |
45 | |
46 | public function getContextSource(): IContextSource { |
47 | return $this->skin->getContext(); |
48 | } |
49 | |
50 | /** |
51 | * @inheritDoc |
52 | */ |
53 | public function getConfig(): Config { |
54 | return $this->skin->getConfig(); |
55 | } |
56 | |
57 | /** |
58 | * @inheritDoc |
59 | */ |
60 | public function getTitle(): Title { |
61 | return $this->skin->getTitle() ?? Title::makeTitle( NS_MAIN, 'Foo' ); |
62 | } |
63 | |
64 | /** |
65 | * @return Title|null the "relevant" title - see Skin::getRelevantTitle |
66 | */ |
67 | public function getRelevantTitle() { |
68 | return $this->skin->getRelevantTitle() ?? $this->getTitle(); |
69 | } |
70 | |
71 | public function getOutput(): OutputPage { |
72 | return $this->skin->getOutput(); |
73 | } |
74 | |
75 | /** |
76 | * @return User |
77 | */ |
78 | public function getUser() { |
79 | return $this->skin->getUser(); |
80 | } |
81 | |
82 | /** |
83 | * @return Language $language |
84 | */ |
85 | public function getLanguage() { |
86 | return $this->skin->getLanguage(); |
87 | } |
88 | |
89 | public function getMessageLocalizer(): MessageLocalizer { |
90 | if ( $this->localizer === null ) { |
91 | // Cannot call getContext in constructor, |
92 | // because Skin::class does not have a context yet. |
93 | // But it is valid to call it now |
94 | $this->localizer = $this->skin->getContext(); |
95 | } |
96 | |
97 | return $this->localizer; |
98 | } |
99 | |
100 | /** |
101 | * @return WikiPage |
102 | */ |
103 | public function getWikiPage() { |
104 | return $this->skin->getWikiPage(); |
105 | } |
106 | } |