Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 19 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
EchoGetStartedPresentationModel | |
0.00% |
0 / 19 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getSecondaryLinks | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 | |||
getPrimaryLink | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
getSpecialHomepageUrl | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\LevelingUp; |
4 | |
5 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
6 | |
7 | /** |
8 | * Echo notification for "Get Started" (T322435) |
9 | */ |
10 | class EchoGetStartedPresentationModel extends EchoEventPresentationModel { |
11 | |
12 | /** @inheritDoc */ |
13 | public function getIconType() { |
14 | return 'growthexperiments-get-started'; |
15 | } |
16 | |
17 | /** @inheritDoc */ |
18 | public function getHeaderMessage() { |
19 | return $this->getMessageWithAgent( 'growthexperiments-levelingup-getstarted-notification-header' ); |
20 | } |
21 | |
22 | /** @inheritDoc */ |
23 | public function getSecondaryLinks() { |
24 | // We don't include the secondary link in email, because it's the same as the primary link, |
25 | // and it looks awkward in an email to have two buttons leading to the same thing. |
26 | if ( $this->getDistributionType() === 'email' ) { |
27 | return []; |
28 | } |
29 | return [ [ |
30 | 'url' => $this->getSpecialHomepageUrl( 'get-started-secondary-link' ), |
31 | 'label' => $this->msg( 'growthexperiments-levelingup-getstarted-notification-call-to-action-label' ), |
32 | 'icon' => 'edit' |
33 | ] ]; |
34 | } |
35 | |
36 | /** @inheritDoc */ |
37 | public function getPrimaryLink() { |
38 | return [ |
39 | 'url' => $this->getSpecialHomepageUrl( 'get-started-primary-link-' . $this->getDistributionType() ), |
40 | 'label' => $this->msg( |
41 | 'growthexperiments-levelingup-getstarted-notification-call-to-action-label' |
42 | )->text(), |
43 | 'icon' => 'edit' |
44 | ]; |
45 | } |
46 | |
47 | private function getSpecialHomepageUrl( string $source ): string { |
48 | $title = $this->event->getTitle(); |
49 | $title->setFragment( '#/homepage/suggested-edits' ); |
50 | return $title->getCanonicalURL( [ 'source' => $source ] ); |
51 | } |
52 | } |