Jump to content

Manual:Hooks/ApiOptions: Difference between revisions

From mediawiki.org
Content deleted Content added
basic documentation for hook
Tag: 2017 source edit
 
m add gerrit changeset
Tag: 2017 source edit
 
Line 3: Line 3:
|name = ApiOptions
|name = ApiOptions
|version = 1.33.0
|version = 1.33.0
|gerrit =
|gerrit =
|removed =
|removed =
|summary = Called by action=options before applying changes to user preferences.
|summary = Called by action=options before applying changes to user preferences.

Latest revision as of 01:34, 4 July 2019

ApiOptions
Available from version 1.33.0 (Gerrit change 447730)
Called by action=options before applying changes to user preferences.
Define function:
public static function onApiOptions( ApiOptions $apiModule, User $user, array $changes, array $resetKinds ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"ApiOptions": "MediaWiki\\Extension\\MyExtension\\Hooks::onApiOptions"
	}
}
Called from: File(s): api/ApiOptions.php
Function(s): execute
Interface: ApiOptionsHook.php

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


Details[edit]

  • $apiModule: Calling ApiOptions object
  • $user: User object whose preferences are being changed
  • $changes: Associative array of preference name => value
  • $resetKinds: Array of strings specifying which options kinds to reset. See User::resetOptions() and User::getOptionKinds() for possible values.