Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 26 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
MentionPresentationModel | |
0.00% |
0 / 26 |
|
0.00% |
0 / 8 |
132 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
canRender | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPrimaryLink | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
getSecondaryLinks | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessageKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessage | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 | |||
getBodyMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getRevisionType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace Flow\Notifications; |
4 | |
5 | class MentionPresentationModel extends FlowPresentationModel { |
6 | |
7 | /** @inheritDoc */ |
8 | public function getIconType() { |
9 | return 'mention'; |
10 | } |
11 | |
12 | /** @inheritDoc */ |
13 | public function canRender() { |
14 | return $this->hasTitle(); |
15 | } |
16 | |
17 | /** @inheritDoc */ |
18 | public function getPrimaryLink() { |
19 | $link = [ |
20 | 'url' => $this->event->getTitle()->getFullURL(), |
21 | 'label' => $this->msg( 'notification-link-text-view-mention' )->text() |
22 | ]; |
23 | |
24 | // override url, link straight to that specific post/topic |
25 | if ( $this->getRevisionType() === 'post' ) { |
26 | $link['url'] = $this->getPostLinkUrl(); |
27 | } elseif ( $this->getRevisionType() === 'post-summary' ) { |
28 | $link['url'] = $this->getTopicLinkUrl(); |
29 | } |
30 | |
31 | return $link; |
32 | } |
33 | |
34 | /** @inheritDoc */ |
35 | public function getSecondaryLinks() { |
36 | return [ |
37 | $this->getAgentLink(), |
38 | $this->getBoardByNewestLink(), |
39 | ]; |
40 | } |
41 | |
42 | /** @inheritDoc */ |
43 | public function getHeaderMessageKey() { |
44 | return parent::getHeaderMessageKey() . '-' . $this->getRevisionType(); |
45 | } |
46 | |
47 | /** @inheritDoc */ |
48 | public function getHeaderMessage() { |
49 | $msg = parent::getHeaderMessage(); |
50 | $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
51 | $msg->params( $this->getViewingUserForGender() ); |
52 | |
53 | if ( in_array( $this->getRevisionType(), [ 'post', 'post-summary' ] ) ) { |
54 | $msg->plaintextParams( $this->getTopicTitle() ); |
55 | } |
56 | |
57 | return $msg; |
58 | } |
59 | |
60 | /** @inheritDoc */ |
61 | public function getBodyMessage() { |
62 | $msg = $this->msg( "notification-body-{$this->type}" ); |
63 | $msg->plaintextParams( $this->getContentSnippet() ); |
64 | return $msg; |
65 | } |
66 | |
67 | protected function getRevisionType() { |
68 | // we didn't use to include the type to differentiate messages, but |
69 | // then we only supported posts |
70 | return $this->event->getExtraParam( 'revision-type', 'post' ); |
71 | } |
72 | } |