mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Echo
synced 2024-12-21 04:03:40 +00:00
7e3d73c11b
Most notably: * Use the much more narrow UserIdentity interface where possible. * Make array type hints in PHPDocs as specific as possible. Change-Id: Id189da4028b7874909277881dcf6539169dd13b6
37 lines
1 KiB
PHP
37 lines
1 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Notifications\Formatters;
|
|
|
|
/**
|
|
* 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 ): array {
|
|
$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;
|
|
}
|
|
}
|