mediawiki-extensions-Echo/includes/formatters/EchoModelFormatter.php
Stephane Bisson cf71009638 Remove deprecated formatter
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
2016-07-20 11:00:34 -04:00

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;
}
}