MediaWiki  master
ApiClearHasMsg.php
Go to the documentation of this file.
1 <?php
2 
25 
30 class ApiClearHasMsg extends ApiBase {
31 
34 
40  public function __construct(
41  ApiMain $main,
42  $action,
44  ) {
45  parent::__construct( $main, $action );
46  $this->talkPageNotificationManager = $talkPageNotificationManager;
47  }
48 
49  public function execute() {
50  $this->talkPageNotificationManager->removeUserHasNewMessages( $this->getUser() );
51 
52  $this->getResult()->addValue( null, $this->getModuleName(), 'success' );
53  }
54 
55  public function isWriteMode() {
56  return true;
57  }
58 
59  public function mustBePosted() {
60  return true;
61  }
62 
63  protected function getExamplesMessages() {
64  return [
65  'action=clearhasmsg'
66  => 'apihelp-clearhasmsg-example-1',
67  ];
68  }
69 
70  public function getHelpUrls() {
71  return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:ClearHasMsg';
72  }
73 }
ApiMain
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:49
ApiBase\getResult
getResult()
Get the result object.
Definition: ApiBase.php:628
ApiClearHasMsg\execute
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
Definition: ApiClearHasMsg.php:49
ApiClearHasMsg\mustBePosted
mustBePosted()
Indicates whether this module must be called with a POST request.
Definition: ApiClearHasMsg.php:59
ContextSource\getUser
getUser()
Definition: ContextSource.php:136
ApiClearHasMsg
API module that clears the hasmsg flag for current user.
Definition: ApiClearHasMsg.php:30
ApiBase
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:55
MediaWiki\User\TalkPageNotificationManager
Manages user talk page notifications.
Definition: TalkPageNotificationManager.php:35
ApiClearHasMsg\__construct
__construct(ApiMain $main, $action, TalkPageNotificationManager $talkPageNotificationManager)
Definition: ApiClearHasMsg.php:40
ApiClearHasMsg\isWriteMode
isWriteMode()
Indicates whether this module requires write mode.
Definition: ApiClearHasMsg.php:55
ApiClearHasMsg\getExamplesMessages
getExamplesMessages()
Returns usage examples for this module.
Definition: ApiClearHasMsg.php:63
ApiClearHasMsg\$talkPageNotificationManager
TalkPageNotificationManager $talkPageNotificationManager
Definition: ApiClearHasMsg.php:33
ApiClearHasMsg\getHelpUrls
getHelpUrls()
Return links to more detailed help pages about the module.
Definition: ApiClearHasMsg.php:70
ApiBase\getModuleName
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:497