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