Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
AbstractEditorCapability | |
0.00% |
0 / 6 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getContext | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getParentTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
msg | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\CommunityConfiguration\EditorCapabilities; |
4 | |
5 | use MediaWiki\Context\IContextSource; |
6 | use MediaWiki\Message\Message; |
7 | use MediaWiki\Title\Title; |
8 | use MessageLocalizer; |
9 | use MessageSpecifier; |
10 | use Psr\Log\LoggerAwareTrait; |
11 | use Psr\Log\NullLogger; |
12 | |
13 | abstract class AbstractEditorCapability implements IEditorCapability, MessageLocalizer { |
14 | use LoggerAwareTrait; |
15 | |
16 | private IContextSource $ctx; |
17 | private Title $parentTitle; |
18 | |
19 | public function __construct( IContextSource $ctx, Title $parentTitle ) { |
20 | $this->ctx = $ctx; |
21 | $this->parentTitle = $parentTitle; |
22 | |
23 | $this->setLogger( new NullLogger() ); |
24 | } |
25 | |
26 | /** |
27 | * Return the context |
28 | * |
29 | * @return IContextSource |
30 | */ |
31 | final protected function getContext(): IContextSource { |
32 | return $this->ctx; |
33 | } |
34 | |
35 | /** |
36 | * Return the parent page's title |
37 | * |
38 | * The capability is included in a special page; this method returns the root title for that |
39 | * page, disregarding any subpages. |
40 | * |
41 | * @return Title |
42 | */ |
43 | final protected function getParentTitle(): Title { |
44 | return $this->parentTitle; |
45 | } |
46 | |
47 | /** |
48 | * Wrapper around wfMessage that sets the current context. |
49 | * |
50 | * @param string|string[]|MessageSpecifier $key |
51 | * @param mixed ...$params |
52 | * @return Message |
53 | * @see wfMessage |
54 | */ |
55 | public function msg( $key, ...$params ) { |
56 | return $this->getContext()->msg( $key, ...$params ); |
57 | } |
58 | } |