mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-11 07:26:29 +00:00
cf71009638
Followup to I639b9d9906d3ff37021cb9b5ed3cb401354b5bd9 * Remove deprecated formatter * Log a warning and fail gracefully when an event type does not support Echo presentation model. Bug: T121612 Change-Id: Ic5712c4ce265b6faabce7a4028b4294fe3c73f18
32 lines
834 B
PHP
32 lines
834 B
PHP
<?php
|
|
|
|
/**
|
|
* A formatter for the notification flyout popup. Just the bare data needed to
|
|
* render everything client-side.
|
|
*/
|
|
class EchoModelFormatter extends EchoEventFormatter {
|
|
/**
|
|
* @param EchoEventPresentationModel $model
|
|
* @return array
|
|
*/
|
|
protected function formatModel( EchoEventPresentationModel $model ) {
|
|
$data = $model->jsonSerialize();
|
|
$data['iconUrl'] = EchoIcon::getUrl( $model->getIconType(), $this->language->getDir() );
|
|
|
|
if ( isset( $data['links']['primary']['url'] ) ) {
|
|
$data['links']['primary']['url'] = wfExpandUrl( $data['links']['primary']['url'] );
|
|
}
|
|
|
|
foreach ( $data['links']['secondary'] as &$link ) {
|
|
$link['url'] = wfExpandUrl( $link['url'] );
|
|
}
|
|
|
|
$bundledIds = $model->getBundledIds();
|
|
if ( $bundledIds ) {
|
|
$data[ 'bundledIds' ] = $bundledIds;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|