mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-30 18:45:07 +00:00
Don't use $wgLang in DataOutputFormatter
Require callers to pass it in. Change-Id: I94ec940495a681151b289294186121462d4b5b5c
This commit is contained in:
parent
f40ef7019f
commit
1f366807d6
|
@ -18,9 +18,10 @@ class EchoDataOutputFormatter {
|
|||
* @param EchoNotification $notification
|
||||
* @param string|bool $format specifify output format, false to not format any notifications
|
||||
* @param User $user the target user viewing the notification
|
||||
* @param Language $lang Language to format the notification in
|
||||
* @return array
|
||||
*/
|
||||
public static function formatOutput( EchoNotification $notification, $format = false, User $user ) {
|
||||
public static function formatOutput( EchoNotification $notification, $format = false, User $user, Language $lang ) {
|
||||
$event = $notification->getEvent();
|
||||
$timestamp = $notification->getTimestamp();
|
||||
$utcTimestampUnix = wfTimestamp( TS_UNIX, $timestamp );
|
||||
|
@ -108,21 +109,18 @@ class EchoDataOutputFormatter {
|
|||
}
|
||||
|
||||
if ( $format ) {
|
||||
$output['*'] = self::formatNotification( $event, $user, $format );
|
||||
$output['*'] = self::formatNotification( $event, $user, $format, $lang );
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
protected static function formatNotification( EchoEvent $event, User $user, $format ) {
|
||||
global $wgLang;
|
||||
protected static function formatNotification( EchoEvent $event, User $user, $format, $lang ) {
|
||||
if ( isset( self::$formatters[$format] )
|
||||
&& EchoEventPresentationModel::supportsPresentationModel( $event->getType() )
|
||||
) {
|
||||
// FIXME don't use $wgLang. It's ok because this is only used for the API or Special page, and not
|
||||
// emails yet.
|
||||
/** @var EchoEventFormatter $formatter */
|
||||
$formatter = new self::$formatters[$format]( $user, $wgLang );
|
||||
$formatter = new self::$formatters[$format]( $user, $lang );
|
||||
return $formatter->format( $event );
|
||||
} else {
|
||||
// Legacy b/c
|
||||
|
|
|
@ -146,7 +146,9 @@ class ApiEchoNotifications extends ApiQueryBase {
|
|||
|
||||
wfProfileIn( __METHOD__ . '-formatting' );
|
||||
foreach ( $notifs as $notif ) {
|
||||
$result['list'][$notif->getEvent()->getID()] = EchoDataOutputFormatter::formatOutput( $notif, $format, $user );
|
||||
$result['list'][$notif->getEvent()->getID()] = EchoDataOutputFormatter::formatOutput(
|
||||
$notif, $format, $user, $this->getLanguage()
|
||||
);
|
||||
}
|
||||
wfProfileOut( __METHOD__ . '-formatting' );
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class SpecialNotifications extends SpecialPage {
|
|||
$attributeManager->getUserEnabledEvents( $user, 'web' )
|
||||
);
|
||||
foreach ( $notifications as $notification ) {
|
||||
$notif[] = EchoDataOutputFormatter::formatOutput( $notification, 'html', $user );
|
||||
$notif[] = EchoDataOutputFormatter::formatOutput( $notification, 'html', $user, $this->getLanguage() );
|
||||
}
|
||||
|
||||
// If there are no notifications, display a message saying so
|
||||
|
|
Loading…
Reference in a new issue