Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
PageTriagePresentationModel | |
0.00% |
0 / 16 |
|
0.00% |
0 / 5 |
72 | |
0.00% |
0 / 1 |
canRender | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPrimaryLink | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
getTags | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTagsForOutput | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
getBodyMessage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\PageTriage\Notifications; |
4 | |
5 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
6 | use MediaWiki\Title\Title; |
7 | |
8 | abstract class PageTriagePresentationModel extends EchoEventPresentationModel { |
9 | /** |
10 | * @inheritDoc |
11 | */ |
12 | public function canRender() { |
13 | return $this->event->getTitle() instanceof Title; |
14 | } |
15 | |
16 | /** |
17 | * @inheritDoc |
18 | */ |
19 | public function getPrimaryLink() { |
20 | $title = $this->event->getTitle(); |
21 | $url = $title->getFullUrl( |
22 | $title->isRedirect() ? [ 'redirect' => 'no' ] : "" |
23 | ); |
24 | return [ |
25 | 'url' => $url, |
26 | 'label' => $this->msg( 'notification-link-text-view-page' )->text(), |
27 | ]; |
28 | } |
29 | |
30 | /** |
31 | * @return string[] |
32 | */ |
33 | protected function getTags() { |
34 | // BC: the extra params array used to be the tags directly, now the tags are under the key 'tags' |
35 | return $this->event->getExtraParam( 'tags', $this->event->getExtra() ); |
36 | } |
37 | |
38 | /** |
39 | * Returns an array of [tag list, amount of tags], to be used as msg params. |
40 | * |
41 | * @return array [(string) tag list, (int) amount of tags] |
42 | */ |
43 | protected function getTagsForOutput() { |
44 | $tags = $this->getTags(); |
45 | |
46 | if ( !is_array( $tags ) ) { |
47 | return [ '', 0 ]; |
48 | } |
49 | |
50 | return [ $this->language->commaList( $tags ), count( $tags ) ]; |
51 | } |
52 | |
53 | /** |
54 | * @inheritDoc |
55 | */ |
56 | public function getBodyMessage() { |
57 | $note = $this->event->getExtraParam( 'note' ); |
58 | return $note ? $this->msg( 'notification-body-page-triage-note' )->params( $note ) : false; |
59 | } |
60 | } |