mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-11-24 07:54:13 +00:00
e21e3b4a8d
Change-Id: I65ae6adc10941c05a2646e551b1baa829e4e8654
33 lines
895 B
PHP
33 lines
895 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 ) {
|
|
// @phan-suppress-next-line PhanTypeMismatchDimAssignment
|
|
$link['url'] = wfExpandUrl( $link['url'] );
|
|
}
|
|
|
|
$bundledIds = $model->getBundledIds();
|
|
if ( $bundledIds ) {
|
|
$data[ 'bundledIds' ] = $bundledIds;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|