Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| EnablePresentationModel | |
0.00% |
0 / 15 |
|
0.00% |
0 / 4 |
30 | |
0.00% |
0 / 1 |
| getIconType | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPrimaryLink | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getSecondaryLinks | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
6 | |||
| getBodyMessage | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | declare( strict_types=1 ); |
| 3 | /** |
| 4 | * Copyright (C) 2022 Kunal Mehta <legoktm@debian.org> |
| 5 | * |
| 6 | * @license GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | namespace MediaWiki\Extension\OATHAuth\Notifications; |
| 10 | |
| 11 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
| 12 | use MediaWiki\SpecialPage\SpecialPage; |
| 13 | use MediaWiki\Title\Title; |
| 14 | |
| 15 | /** |
| 16 | * Notification sent when 2FA (first factor) has been enabled for this user |
| 17 | */ |
| 18 | class EnablePresentationModel extends EchoEventPresentationModel { |
| 19 | |
| 20 | /** @inheritDoc */ |
| 21 | public function getIconType() { |
| 22 | return 'site'; |
| 23 | } |
| 24 | |
| 25 | /** @inheritDoc */ |
| 26 | public function getPrimaryLink() { |
| 27 | return [ |
| 28 | 'url' => SpecialPage::getTitleFor( 'OATHManage' )->getLocalURL(), |
| 29 | 'label' => $this->msg( 'oathauth-notifications-enable-primary' )->text() |
| 30 | ]; |
| 31 | } |
| 32 | |
| 33 | /** @inheritDoc */ |
| 34 | public function getSecondaryLinks() { |
| 35 | $link = $this->msg( 'oathauth-notifications-enable-helplink' )->inContentLanguage(); |
| 36 | $title = Title::newFromText( $link->plain() ); |
| 37 | if ( !$title ) { |
| 38 | // Invalid title, skip |
| 39 | return []; |
| 40 | } |
| 41 | return [ [ |
| 42 | 'url' => $title->getLocalURL(), |
| 43 | 'label' => $this->msg( 'oathauth-notifications-enable-help' )->text(), |
| 44 | 'icon' => 'help', |
| 45 | ] ]; |
| 46 | } |
| 47 | |
| 48 | /** @inheritDoc */ |
| 49 | public function getBodyMessage() { |
| 50 | return $this->getMessageWithAgent( 'notification-body-oathauth-enable' ); |
| 51 | } |
| 52 | } |