Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
EchoKeepGoingPresentationModel
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 5
42
0.00% covered (danger)
0.00%
0 / 1
 getIconType
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHeaderMessage
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getSecondaryLinks
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
6
 getPrimaryLink
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 getSpecialHomepageUrl
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace GrowthExperiments\LevelingUp;
4
5use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel;
6
7/**
8 * Echo notification for "Keep going" (T328288)
9 */
10class EchoKeepGoingPresentationModel extends EchoEventPresentationModel {
11
12    /** @inheritDoc */
13    public function getIconType() {
14        return 'growthexperiments-keep-going';
15    }
16
17    /** @inheritDoc */
18    public function getHeaderMessage() {
19        return $this->getMessageWithAgent( 'growthexperiments-levelingup-keepgoing-notification-header' )
20            ->params( $this->event->getExtra()['suggestededitcount'] );
21    }
22
23    /** @inheritDoc */
24    public function getSecondaryLinks() {
25        // We don't include the secondary link in email, because it's the same as the primary link,
26        // and it looks awkward in an email to have two buttons leading to the same thing.
27        if ( $this->getDistributionType() === 'email' ) {
28            return [];
29        }
30        return [ [
31            'url' => $this->getSpecialHomepageUrl( 'keep-going-secondary-link' ),
32            'label' => $this->getMessageWithAgent(
33                'growthexperiments-levelingup-keepgoing-notification-call-to-action-label'
34            ),
35            'icon' => 'edit'
36        ] ];
37    }
38
39    /** @inheritDoc */
40    public function getPrimaryLink() {
41        return [
42            'url' => $this->getSpecialHomepageUrl( 'keep-going-primary-link-' . $this->getDistributionType() ),
43            'label' => $this->msg( 'growthexperiments-levelingup-keepgoing-notification-call-to-action-label' )->text()
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}