MediaWiki  master
ApiClearHasMsg.php
Go to the documentation of this file.
1 <?php
2 
25 
30 class ApiClearHasMsg extends ApiBase {
31 
33  private $talkPageNotificationManager;
34 
40  public function __construct(
41  ApiMain $main,
42  $action,
43  TalkPageNotificationManager $talkPageNotificationManager
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 }
This abstract class implements many basic API functions, and is the base of all API classes.
Definition: ApiBase.php:58
getResult()
Get the result object.
Definition: ApiBase.php:636
getModuleName()
Get the name of the module being executed by this instance.
Definition: ApiBase.php:505
API module that clears the hasmsg flag for current user.
mustBePosted()
Indicates whether this module must be called with a POST request.
getExamplesMessages()
Returns usage examples for this module.
isWriteMode()
Indicates whether this module requires write mode.
__construct(ApiMain $main, $action, TalkPageNotificationManager $talkPageNotificationManager)
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
This is the main API class, used for both external and internal processing.
Definition: ApiMain.php:56