| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Extension\Notifications\Formatters; |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
class EchoModelFormatter extends EchoEventFormatter { |
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
protected function formatModel( EchoEventPresentationModel $model ): array { |
| 15 |
$data = $model->jsonSerialize(); |
| 16 |
$data['iconUrl'] = EchoIcon::getUrl( $model->getIconType(), $this->language->getDir() ); |
| 17 |
|
| 18 |
if ( isset( $data['links']['primary']['url'] ) ) { |
| 19 |
$data['links']['primary']['url'] = wfExpandUrl( $data['links']['primary']['url'] ); |
| 20 |
} |
| 21 |
|
| 22 |
|
| 23 |
foreach ( $data['links']['secondary'] as &$link ) { |
| 24 |
|
| 25 |
$link['url'] = wfExpandUrl( $link['url'] ); |
| 26 |
} |
| 27 |
unset( $link ); |
| 28 |
|
| 29 |
$bundledIds = $model->getBundledIds(); |
| 30 |
if ( $bundledIds ) { |
| 31 |
$data[ 'bundledIds' ] = $bundledIds; |
| 32 |
} |
| 33 |
|
| 34 |
return $data; |
| 35 |
} |
| 36 |
} |