mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-12-04 21:08:32 +00:00
3dc5e88842
Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: I492ddae3c3e9f81d551ea8b348b7148893f4f590
61 lines
1.5 KiB
PHP
61 lines
1.5 KiB
PHP
<?php
|
|
/**
|
|
* Our override of the built-in Echo presentation model for user talk page notifications.
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace MediaWiki\Extension\DiscussionTools\Notifications;
|
|
|
|
use MediaWiki\Extension\Notifications\Formatters\EchoEditUserTalkPresentationModel;
|
|
use MediaWiki\Language\RawMessage;
|
|
use MediaWiki\Message\Message;
|
|
use Wikimedia\Timestamp\TimestampException;
|
|
|
|
class EnhancedEchoEditUserTalkPresentationModel extends EchoEditUserTalkPresentationModel {
|
|
|
|
use DiscussionToolsEventTrait;
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getPrimaryLink() {
|
|
$linkInfo = parent::getPrimaryLink();
|
|
// For events enhanced by DiscussionTools: link to the individual comment
|
|
$link = $this->getCommentLink();
|
|
if ( $link ) {
|
|
$linkInfo['url'] = $link;
|
|
}
|
|
return $linkInfo;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getBodyMessage() {
|
|
if ( !$this->isBundled() ) {
|
|
// For events enhanced by DiscussionTools: add a text snippet
|
|
// (Echo can only do this for new sections, not for every comment)
|
|
$snippet = $this->getContentSnippet();
|
|
if ( $snippet ) {
|
|
return new RawMessage( '$1', [ Message::plaintextParam( $snippet ) ] );
|
|
}
|
|
}
|
|
return parent::getBodyMessage();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @throws TimestampException
|
|
*/
|
|
public function jsonSerialize(): array {
|
|
$array = parent::jsonSerialize();
|
|
|
|
$array['links']['legacyPrimary'] = $this->addMarkAsRead( parent::getPrimaryLink() ) ?: [];
|
|
|
|
return $array;
|
|
}
|
|
}
|