Manual:Hooks/ApiQueryTokensRegisterTypes

From MediaWiki.org
Jump to navigation Jump to search
ApiQueryTokensRegisterTypes
Available from version 1.24.0 (Gerrit change 153110)
Use this hook to add additional token types to action=query&meta=tokens. Note that most modules will probably be able to use the 'csrf' token instead of creating their own token types.
Define function:
public static function onApiQueryTokensRegisterTypes( &$salts ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ApiQueryTokensRegisterTypes": "MyExtensionHooks::onApiQueryTokensRegisterTypes"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ApiQueryTokensRegisterTypes'][] = 'MyExtensionHooks::onApiQueryTokensRegisterTypes';
Called from: File(s): ApiQueryTokens.php
Function(s): getTokenTypeSalts

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:ApiQueryTokensRegisterTypes extensions.

Details[edit]

  • &$salts: array( type => salt to pass to User::getEditToken() or array of salt and key to pass to Session::getToken() )