Debian Codegraph @

extensions/Echo/includes/Formatters/EchoModelFormatter.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\Formatters;
4
5 /**
6 * A formatter for the notification flyout popup. Just the bare data needed to
7 * render everything client-side.
8 */
9 class EchoModelFormatter extends EchoEventFormatter {
10 /**
11 * @param EchoEventPresentationModel $model
12 * @return array
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 // @phan-suppress-next-line PhanTypePossiblyInvalidDimOffset
23 foreach ( $data['links']['secondary'] as &$link ) {
24 // @phan-suppress-next-line PhanTypeMismatchDimAssignment
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 }