Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ThanksLogFormatter | |
0.00% |
0 / 8 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getMessageParameters | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
getPreloadTitles | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\Thanks; |
4 | |
5 | use LogEntry; |
6 | use LogFormatter; |
7 | use MediaWiki\Message\Message; |
8 | use MediaWiki\Title\NamespaceInfo; |
9 | use MediaWiki\User\User; |
10 | |
11 | /** |
12 | * This class formats log entries for thanks |
13 | */ |
14 | class ThanksLogFormatter extends LogFormatter { |
15 | private NamespaceInfo $namespaceInfo; |
16 | |
17 | public function __construct( |
18 | LogEntry $entry, |
19 | NamespaceInfo $namespaceInfo |
20 | ) { |
21 | parent::__construct( $entry ); |
22 | $this->namespaceInfo = $namespaceInfo; |
23 | } |
24 | |
25 | /** |
26 | * @inheritDoc |
27 | */ |
28 | protected function getMessageParameters() { |
29 | $params = parent::getMessageParameters(); |
30 | // Convert target from a pageLink to a userLink since the target is |
31 | // actually a user, not a page. |
32 | $recipient = User::newFromName( $this->entry->getTarget()->getText(), false ); |
33 | $params[2] = Message::rawParam( $this->makeUserLink( $recipient ) ); |
34 | $params[3] = $recipient->getName(); |
35 | return $params; |
36 | } |
37 | |
38 | public function getPreloadTitles() { |
39 | // Add the recipient's user talk page to LinkBatch |
40 | return [ $this->namespaceInfo->getTalkPage( $this->entry->getTarget() ) ]; |
41 | } |
42 | } |