Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
UnsubscribeInactiveUsersPresentationModel | |
0.00% |
0 / 13 |
|
0.00% |
0 / 5 |
42 | |
0.00% |
0 / 1 |
getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getHeaderMessageKey | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getBodyMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPrimaryLink | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
locateUsers | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\TranslationNotifications; |
5 | |
6 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
7 | use MediaWiki\Extension\Notifications\Model\Event; |
8 | use MediaWiki\MediaWikiServices; |
9 | use MediaWiki\SpecialPage\SpecialPage; |
10 | |
11 | /** |
12 | * Presentation model for the translation notification unsubscribed event |
13 | * @author Abijeet Patro |
14 | * @copyright Copyright © 2023 |
15 | * @license GPL-2.0-or-later |
16 | */ |
17 | class UnsubscribeInactiveUsersPresentationModel extends EchoEventPresentationModel { |
18 | /** @inheritDoc */ |
19 | public function getIconType() { |
20 | return 'placeholder'; |
21 | } |
22 | |
23 | /** @inheritDoc */ |
24 | public function getHeaderMessageKey() { |
25 | return 'translationnotifications-echo-unsubscribe-header'; |
26 | } |
27 | |
28 | /** @inheritDoc */ |
29 | public function getBodyMessage() { |
30 | return $this->msg( 'translationnotifications-echo-unsubscribe-body' ); |
31 | } |
32 | |
33 | /** @inheritDoc */ |
34 | public function getPrimaryLink() { |
35 | return [ |
36 | 'url' => SpecialPage::getTitleFor( 'TranslatorSignup' )->getFullURL(), |
37 | 'label' => $this->msg( 'translationnotifications-echo-unsubscribe-primary-label' )->plain() |
38 | ]; |
39 | } |
40 | |
41 | public static function locateUsers( Event $event ): array { |
42 | $extra = $event->getExtra(); |
43 | $userId = $extra[ 'userId' ] ?? null; |
44 | if ( $userId === null ) { |
45 | return []; |
46 | } |
47 | |
48 | $userFactory = MediaWikiServices::getInstance()->getUserFactory(); |
49 | return [ $userFactory->newFromId( $userId ) ]; |
50 | } |
51 | } |