Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
EchoMentorChangePresentationModel | |
0.00% |
0 / 27 |
|
0.00% |
0 / 5 |
90 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getHeaderMessage | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getBodyMessage | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
getPrimaryLink | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
getSecondaryLinks | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Mentorship; |
4 | |
5 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
6 | |
7 | class EchoMentorChangePresentationModel extends EchoEventPresentationModel { |
8 | |
9 | /** |
10 | * @inheritDoc |
11 | */ |
12 | public function getIconType() { |
13 | if ( in_array( $this->language->getCode(), [ 'he', 'yi' ] ) ) { |
14 | // T332732: In he, the mentor icon should be displayed in LTR |
15 | return 'growthexperiments-mentor-ltr'; |
16 | } |
17 | return 'growthexperiments-mentor'; |
18 | } |
19 | |
20 | /** |
21 | * @inheritDoc |
22 | */ |
23 | public function getHeaderMessage() { |
24 | return $this->getMessageWithAgent( 'growthexperiments-notification-header-mentor-change' ) |
25 | ->params( $this->getUser()->getName() ); |
26 | } |
27 | |
28 | /** |
29 | * @inheritDoc |
30 | */ |
31 | public function getBodyMessage() { |
32 | $extra = $this->event->getExtra(); |
33 | if ( array_key_exists( 'reason', $extra ) && $extra['reason'] !== '' ) { |
34 | // B&C: pre-T327493 notification |
35 | return $this->msg( 'growthexperiments-notification-body-mentor-change' ) |
36 | ->params( $extra['reason'] ); |
37 | } elseif ( array_key_exists( 'oldMentor', $extra ) ) { |
38 | return $this->msg( 'growthexperiments-notification-body-mentor-change-new' ) |
39 | ->params( $extra['oldMentor'] ); |
40 | } |
41 | return false; |
42 | } |
43 | |
44 | /** |
45 | * @inheritDoc |
46 | */ |
47 | public function getPrimaryLink() { |
48 | return [ |
49 | 'url' => $this->event->getAgent()->getUserPage()->getLocalURL(), |
50 | 'label' => $this->msg( 'growthexperiments-notification-learn-more' ) |
51 | ->params( $this->getUser()->getName() ) |
52 | ->params( $this->event->getAgent()->getName() ) |
53 | ]; |
54 | } |
55 | |
56 | /** |
57 | * @inheritDoc |
58 | */ |
59 | public function getSecondaryLinks() { |
60 | $sayHi = $this->getMessageWithAgent( 'growthexperiments-notification-say-hi-mentor-change' ) |
61 | ->params( $this->getUser()->getName() )->text(); |
62 | return [ |
63 | [ |
64 | 'url' => $this->event->getAgent()->getTalkPage()->getLocalURL(), |
65 | 'label' => $sayHi |
66 | ] |
67 | ]; |
68 | } |
69 | |
70 | } |