Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
41.67% |
5 / 12 |
|
50.00% |
3 / 6 |
CRAP | |
0.00% |
0 / 1 |
| ApiClearHasMsg | |
45.45% |
5 / 11 |
|
50.00% |
3 / 6 |
11.84 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| execute | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| isWriteMode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| mustBePosted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getExamplesMessages | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| getHelpUrls | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Copyright © 2014 Petr Bena (benapetr@gmail.com) |
| 5 | * |
| 6 | * @license GPL-2.0-or-later |
| 7 | * @file |
| 8 | */ |
| 9 | |
| 10 | namespace MediaWiki\Api; |
| 11 | |
| 12 | use MediaWiki\User\TalkPageNotificationManager; |
| 13 | |
| 14 | /** |
| 15 | * API module that clears the hasmsg flag for current user |
| 16 | * @ingroup API |
| 17 | */ |
| 18 | class ApiClearHasMsg extends ApiBase { |
| 19 | |
| 20 | private TalkPageNotificationManager $talkPageNotificationManager; |
| 21 | |
| 22 | public function __construct( |
| 23 | ApiMain $main, |
| 24 | string $action, |
| 25 | TalkPageNotificationManager $talkPageNotificationManager |
| 26 | ) { |
| 27 | parent::__construct( $main, $action ); |
| 28 | $this->talkPageNotificationManager = $talkPageNotificationManager; |
| 29 | } |
| 30 | |
| 31 | public function execute() { |
| 32 | $this->talkPageNotificationManager->removeUserHasNewMessages( $this->getUser() ); |
| 33 | |
| 34 | $this->getResult()->addValue( null, $this->getModuleName(), 'success' ); |
| 35 | } |
| 36 | |
| 37 | /** @inheritDoc */ |
| 38 | public function isWriteMode() { |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | /** @inheritDoc */ |
| 43 | public function mustBePosted() { |
| 44 | return true; |
| 45 | } |
| 46 | |
| 47 | /** @inheritDoc */ |
| 48 | protected function getExamplesMessages() { |
| 49 | return [ |
| 50 | 'action=clearhasmsg' |
| 51 | => 'apihelp-clearhasmsg-example-1', |
| 52 | ]; |
| 53 | } |
| 54 | |
| 55 | /** @inheritDoc */ |
| 56 | public function getHelpUrls() { |
| 57 | return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:ClearHasMsg'; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | /** @deprecated class alias since 1.43 */ |
| 62 | class_alias( ApiClearHasMsg::class, 'ApiClearHasMsg' ); |