Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
EchoModelFormatter
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 1
 formatModel
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace 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 */
9class EchoModelFormatter extends EchoEventFormatter {
10    /**
11     * @param EchoEventPresentationModel $model
12     * @return array
13     */
14    protected function formatModel( EchoEventPresentationModel $model ) {
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}