Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 41 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 1 |
| NewTopicPresentationModel | |
0.00% |
0 / 41 |
|
0.00% |
0 / 8 |
306 | |
0.00% |
0 / 1 |
| getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| canRender | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| getPrimaryLink | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| getSecondaryLinks | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getBodyMessage | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| getHeaderMessageKey | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| getHeaderMessage | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getCompactHeaderMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Notifications; |
| 4 | |
| 5 | class NewTopicPresentationModel extends FlowPresentationModel { |
| 6 | |
| 7 | /** @inheritDoc */ |
| 8 | public function getIconType() { |
| 9 | return $this->getType(); |
| 10 | } |
| 11 | |
| 12 | /** @inheritDoc */ |
| 13 | public function canRender() { |
| 14 | return $this->hasTitle() |
| 15 | && $this->hasValidTopicWorkflowId(); |
| 16 | } |
| 17 | |
| 18 | /** @inheritDoc */ |
| 19 | public function getPrimaryLink() { |
| 20 | if ( $this->isBundled() ) { |
| 21 | return $this->getBoardLinkByNewestTopic(); |
| 22 | } else { |
| 23 | return $this->getViewTopicLink(); |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | /** @inheritDoc */ |
| 28 | public function getSecondaryLinks() { |
| 29 | if ( $this->isBundled() ) { |
| 30 | return [ |
| 31 | $this->getFlowUnwatchDynamicActionLink() |
| 32 | ]; |
| 33 | } else { |
| 34 | return [ |
| 35 | $this->getAgentLink(), |
| 36 | $this->getBoardByNewestLink(), |
| 37 | $this->getFlowUnwatchDynamicActionLink() |
| 38 | ]; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | /** @inheritDoc */ |
| 43 | public function getBodyMessage() { |
| 44 | if ( $this->isBundled() ) { |
| 45 | return false; |
| 46 | } elseif ( $this->isUserTalkPage() ) { |
| 47 | $msg = $this->msg( "notification-body-flow-new-topic-user-talk" ); |
| 48 | } else { |
| 49 | $msg = $this->msg( "notification-body-flow-new-topic-v2" ); |
| 50 | } |
| 51 | |
| 52 | $msg->plaintextParams( $this->getContentSnippet() ); |
| 53 | return $msg; |
| 54 | } |
| 55 | |
| 56 | /** @inheritDoc */ |
| 57 | protected function getHeaderMessageKey() { |
| 58 | if ( $this->isBundled() ) { |
| 59 | if ( $this->isUserTalkPage() ) { |
| 60 | return 'notification-bundle-header-flow-new-topic-user-talk'; |
| 61 | } else { |
| 62 | return 'notification-bundle-header-flow-new-topic'; |
| 63 | } |
| 64 | } else { |
| 65 | if ( $this->isUserTalkPage() ) { |
| 66 | return 'notification-header-flow-new-topic-user-talk'; |
| 67 | } else { |
| 68 | return 'notification-header-flow-new-topic-v2'; |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /** @inheritDoc */ |
| 74 | public function getHeaderMessage() { |
| 75 | $msg = $this->msg( $this->getHeaderMessageKey() ); |
| 76 | |
| 77 | if ( $this->isBundled() ) { |
| 78 | $count = $this->getNotificationCountForOutput(); |
| 79 | // Repeat is B/C until unused parameter is removed from translations |
| 80 | $msg->numParams( $count, $count ); |
| 81 | $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
| 82 | } else { |
| 83 | $msg->params( $this->getAgentForOutput() ); |
| 84 | $msg->params( $this->getTruncatedTitleText( $this->event->getTitle(), true ) ); |
| 85 | $msg->plaintextParams( $this->getTopicTitle() ); |
| 86 | } |
| 87 | |
| 88 | return $msg; |
| 89 | } |
| 90 | |
| 91 | /** @inheritDoc */ |
| 92 | public function getCompactHeaderMessage() { |
| 93 | $msg = $this->msg( 'notification-compact-header-flow-new-topic' ); |
| 94 | $msg->plaintextParams( $this->getTopicTitle() ); |
| 95 | return $msg; |
| 96 | } |
| 97 | } |