Manual:Hooks/ApiCheckCanExecute

From Linux Web Expert

ApiCheckCanExecute
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>
Called during ApiMain::checkCanExecute().
<translate> Define function:</translate>
public static function onApiCheckCanExecute( $module, $user, &$message ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ApiCheckCanExecute": "MediaWiki\\Extension\\MyExtension\\Hooks::onApiCheckCanExecute"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> api/ApiMain.php
<translate> Interface:</translate> ApiCheckCanExecuteHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ApiCheckCanExecute extensions</tvar>.</translate>


Details

Called during ApiMain::checkCanExecute(). Use to further authenticate and authorize API clients before executing the module. Return false and set a message to cancel the request.

  • $module: Module object
  • $user: Current user
  • &$message: API usage message to die with. Since 1.27, it is preferred to use an ApiMessage object here. A string or array is currently passed to ApiBase::dieUsageMsg(), but this is planned to change in 1.29.