Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| EnhancedEchoMentionPresentationModel | |
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| getPrimaryLink | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| jsonSerialize | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Our override of the built-in Echo presentation model for user talk page notifications. |
| 4 | * |
| 5 | * @file |
| 6 | * @ingroup Extensions |
| 7 | * @license MIT |
| 8 | */ |
| 9 | |
| 10 | namespace MediaWiki\Extension\DiscussionTools\Notifications; |
| 11 | |
| 12 | use MediaWiki\Extension\Notifications\Formatters\EchoMentionPresentationModel; |
| 13 | use Wikimedia\Timestamp\TimestampException; |
| 14 | |
| 15 | class EnhancedEchoMentionPresentationModel extends EchoMentionPresentationModel { |
| 16 | |
| 17 | use DiscussionToolsEventTrait; |
| 18 | |
| 19 | /** |
| 20 | * @inheritDoc |
| 21 | */ |
| 22 | public function getPrimaryLink() { |
| 23 | $linkInfo = parent::getPrimaryLink(); |
| 24 | // For events enhanced by DiscussionTools: link to the individual comment |
| 25 | $link = $this->getCommentLink(); |
| 26 | if ( $link ) { |
| 27 | $linkInfo['url'] = $link; |
| 28 | } |
| 29 | return $linkInfo; |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * @inheritDoc |
| 34 | * @throws TimestampException |
| 35 | */ |
| 36 | public function jsonSerialize(): array { |
| 37 | $array = parent::jsonSerialize(); |
| 38 | |
| 39 | $array['links']['legacyPrimary'] = $this->addMarkAsRead( parent::getPrimaryLink() ) ?: []; |
| 40 | |
| 41 | return $array; |
| 42 | } |
| 43 | } |