mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-12-16 16:30:32 +00:00
03b8f88fff
Change-Id: I939d6f4d989cf21c0f817d262bf3e4acedcf2ffe
56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
class EchoFlowThanksFormatter extends EchoBasicFormatter {
|
|
|
|
/**
|
|
* @param $event EchoEvent
|
|
* @param $param
|
|
* @param $message Message
|
|
* @param $user User
|
|
*/
|
|
protected function processParam( $event, $param, $message, $user ) {
|
|
if ( $param === 'postlink' ) {
|
|
$this->setTitleLink(
|
|
$event,
|
|
$message,
|
|
[
|
|
'class' => 'mw-echo-diff',
|
|
'linkText' => $this->getMessage( 'notification-flow-thanks-post-link' )->text(),
|
|
'param' => [
|
|
'workflow' => $event->getExtraParam( 'workflow' ),
|
|
],
|
|
'fragment' => "flow-post-{$event->getExtraParam( 'post-id' )}",
|
|
]
|
|
);
|
|
} elseif ( $param === 'topictitle' ) {
|
|
$message->params( $event->getExtraParam( 'topic-title' ) );
|
|
} else {
|
|
parent::processParam( $event, $param, $message, $user );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Overriding implementation in EchoBasicFormatter to support Flow posts
|
|
*
|
|
* @param EchoEvent $event
|
|
* @param User $user The user receiving the notification
|
|
* @param String $destination The destination type for the link, e.g. 'agent'
|
|
* @return Array including target and query parameters
|
|
*/
|
|
protected function getLinkParams( $event, $user, $destination ) {
|
|
$target = null;
|
|
$query = [];
|
|
|
|
if ( $destination === 'post' ) {
|
|
$target = $event->getTitle();
|
|
if ( $target ) {
|
|
$target->setFragment( '#flow-post-' . $event->getExtraParam( 'post-id' ) );
|
|
$query['workflow'] = $event->getExtraParam( 'workflow' );
|
|
}
|
|
return [ $target, $query ];
|
|
} else {
|
|
return parent::getLinkParams( $event, $user, $destination );
|
|
}
|
|
}
|
|
}
|