51 $services = MediaWikiServices::getInstance();
52 $userOptionsManager ??= $services->getUserOptionsManager();
53 $preferencesFactory ??= $services->getPreferencesFactory();
54 parent::__construct( $main, $action, $userOptionsManager, $preferencesFactory );
57 protected function runHook( $user, $changes, $resetKinds ) {
58 $this->
getHookRunner()->onApiOptions( $this, $user, $changes, $resetKinds );
64 if ( $this->getGlobalParam() ===
'ignore' && $manager->isOptionGlobal( $user, $key ) ) {
65 $this->
addWarning( $this->
msg(
'apiwarn-global-option-ignored', $key ) );
79 'ignore' => UserOptionsManager::GLOBAL_IGNORE,
80 'update' => UserOptionsManager::GLOBAL_UPDATE,
81 'override' => UserOptionsManager::GLOBAL_OVERRIDE
82 ][ $this->getGlobalParam() ];
92 private function getGlobalParam() {
93 return $this->extractRequestParams()[
'global'];
101 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Options';
106 'action=options&reset=&token=123ABC'
107 =>
'apihelp-options-example-reset',
108 'action=options&change=skin=vector|hideminor=1&token=123ABC'
109 =>
'apihelp-options-example-change',
110 'action=options&reset=&change=skin=monobook&optionname=nickname&' .
111 'optionvalue=[[User:Beau|Beau]]%20([[User_talk:Beau|talk]])&token=123ABC'
112 =>
'apihelp-options-example-complex',
117 return parent::getAllowedParams() + [
119 ParamValidator::PARAM_TYPE => [
'ignore',
'update',
'override' ],
120 ParamValidator::PARAM_DEFAULT =>
'ignore'
addWarning( $msg, $code=null, $data=null)
Add a warning for this module.
getHookRunner()
Get an ApiHookRunner for running core API hooks.
This is the main API class, used for both external and internal processing.
The base class for core's ApiOptions and two modules in the GlobalPreferences extension.
getUserForUpdates()
Load the user from the primary to reduce CAS errors on double post (T95839) Will throw if the user is...
API module that facilitates the changing of user's preferences.
resetPreferences(array $kinds)
Reset preferences of the specified kinds.
commitChanges()
Applies changes to user preferences.
getExamplesMessages()
Returns usage examples for this module.
setPreference( $preference, $value)
Sets one user preference to be applied by commitChanges()
runHook( $user, $changes, $resetKinds)
Run the ApiOptions hook if applicable.
getHelpUrls()
Return links to more detailed help pages about the module.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
shouldIgnoreKey( $key)
Check whether a key should be ignored.
__construct(ApiMain $main, $action, UserOptionsManager $userOptionsManager=null, PreferencesFactory $preferencesFactory=null)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()