Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 23 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| RecoveryCodeCountPresentationModel | |
0.00% |
0 / 23 |
|
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 / 9 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\OATHAuth\Notifications; |
| 4 | |
| 5 | use MediaWiki\Extension\Notifications\Formatters\EchoEventPresentationModel; |
| 6 | use MediaWiki\MediaWikiServices; |
| 7 | use MediaWiki\SpecialPage\SpecialPage; |
| 8 | use MediaWiki\Title\Title; |
| 9 | |
| 10 | class RecoveryCodeCountPresentationModel extends EchoEventPresentationModel { |
| 11 | |
| 12 | /** @inheritDoc */ |
| 13 | public function getIconType() { |
| 14 | return 'site'; |
| 15 | } |
| 16 | |
| 17 | /** @inheritDoc */ |
| 18 | public function getPrimaryLink() { |
| 19 | return [ |
| 20 | 'url' => SpecialPage::getTitleFor( 'OATHManage' )->getLocalURL(), |
| 21 | 'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-primary' )->text() |
| 22 | ]; |
| 23 | } |
| 24 | |
| 25 | /** @inheritDoc */ |
| 26 | public function getSecondaryLinks() { |
| 27 | $link = $this->msg( 'oathauth-notifications-recoverycodesleft-helplink' )->inContentLanguage(); |
| 28 | $title = Title::newFromText( $link->plain() ); |
| 29 | if ( !$title ) { |
| 30 | // Invalid title, skip |
| 31 | return []; |
| 32 | } |
| 33 | return [ [ |
| 34 | 'url' => $title->getLocalURL(), |
| 35 | 'label' => $this->msg( 'oathauth-notifications-recoverycodesleft-help' )->text(), |
| 36 | 'icon' => 'help', |
| 37 | ] ]; |
| 38 | } |
| 39 | |
| 40 | /** @inheritDoc */ |
| 41 | public function getBodyMessage() { |
| 42 | $msg = $this->getMessageWithAgent( 'notification-body-oathauth-recoverycodesleft' ); |
| 43 | $msg->params( $this->event->getExtraParam( 'codeCount', 0 ) ); |
| 44 | $msg->params( |
| 45 | $this->event->getExtraParam( |
| 46 | 'generatedCount', |
| 47 | MediaWikiServices::getInstance()->getMainConfig()->get( 'OATHRecoveryCodesCount' ) |
| 48 | ) |
| 49 | ); |
| 50 | return $msg; |
| 51 | } |
| 52 | |
| 53 | } |