mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-02 19:36:48 +00:00
43efb95e8b
* mediawiki/mediawiki-phan-config: 0.10.6 → 0.11.0 * php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1 Change-Id: If2e235fb97c0d39c3c14ba7c423ef45f5c0013d0
35 lines
976 B
PHP
35 lines
976 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'] );
|
|
}
|
|
|
|
// @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
|
|
foreach ( $data['links']['secondary'] as &$link ) {
|
|
// @phan-suppress-next-line PhanTypeMismatchDimAssignment
|
|
$link['url'] = wfExpandUrl( $link['url'] );
|
|
}
|
|
unset( $link );
|
|
|
|
$bundledIds = $model->getBundledIds();
|
|
if ( $bundledIds ) {
|
|
$data[ 'bundledIds' ] = $bundledIds;
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
}
|