MediaWiki master
MediaWiki\User\Options\StaticUserOptionsLookup Class Reference

A UserOptionsLookup that's just an array. More...

Inherits MediaWiki\User\Options\UserOptionsLookup.

Collaboration diagram for MediaWiki\User\Options\StaticUserOptionsLookup:

Public Member Functions

 __construct (array $userMap, array $defaults=[])
 
 getDefaultOptions (?UserIdentity $userIdentity=null)
 Combine the language default options with any site-specific and user-specific defaults and add the default language variants.
Parameters
UserIdentity | null$userIdentityUser to look the default up for; set to null to ignore any user-specific defaults (since 1.42)
Returns
array

 
 getOption (UserIdentity $user, string $oname, $defaultOverride=null, bool $ignoreHidden=false, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option.
Parameters
UserIdentity$userThe user to get the option for
string$onameThe option to check
mixed | null$defaultOverrideA default value returned if the option does not exist
bool$ignoreHiddenWhether to ignore the effects of $wgHiddenPrefs
int$queryFlagsA bit field composed of READ_XXX flags
Returns
mixed|null User's current value for the option, Note that while option values retrieved from the database are always strings, default values and values set within the current request and not yet saved may be of another type.
See also
getBoolOption()
getIntOption()

 
 getOptions (UserIdentity $user, int $flags=0, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get all user's options.
Parameters
UserIdentity$userThe user to get the option for
int$flagsBitwise combination of: UserOptionsManager::EXCLUDE_DEFAULTS Exclude user options that are set to the default value. Options that are set to their conditionally default value are not excluded.
int$queryFlagsA bit field composed of READ_XXX flags
Returns
array

 
- Public Member Functions inherited from MediaWiki\User\Options\UserOptionsLookup
 getBoolOption (UserIdentity $user, string $oname, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option, as a boolean value.
 
 getDefaultOption (string $opt, ?UserIdentity $userIdentity=null)
 Get a given default option value.
 
 getIntOption (UserIdentity $user, string $oname, int $defaultOverride=0, int $queryFlags=IDBAccessObject::READ_NORMAL)
 Get the user's current setting for a given option, as an integer value.
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\User\Options\UserOptionsLookup
const EXCLUDE_DEFAULTS = 1
 Exclude user options that are set to their default value.
 

Detailed Description

A UserOptionsLookup that's just an array.

Useful for testing and creating staging environments. Note that unlike UserOptionsManager, no attempt is made to canonicalize user names.

Since
1.36

Definition at line 13 of file StaticUserOptionsLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\Options\StaticUserOptionsLookup::__construct ( array $userMap,
array $defaults = [] )
Parameters
array[]$userMapUser options, username => [ option name => value ]
mixed[]$defaultsDefaults for each option, option name => value

Definition at line 25 of file StaticUserOptionsLookup.php.

Member Function Documentation

◆ getDefaultOptions()

MediaWiki\User\Options\StaticUserOptionsLookup::getDefaultOptions ( ?UserIdentity $userIdentity = null)

Combine the language default options with any site-specific and user-specific defaults and add the default language variants.

Parameters
UserIdentity | null$userIdentityUser to look the default up for; set to null to ignore any user-specific defaults (since 1.42)
Returns
array

Reimplemented from MediaWiki\User\Options\UserOptionsLookup.

Definition at line 31 of file StaticUserOptionsLookup.php.

◆ getOption()

MediaWiki\User\Options\StaticUserOptionsLookup::getOption ( UserIdentity $user,
string $oname,
$defaultOverride = null,
bool $ignoreHidden = false,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Get the user's current setting for a given option.

Parameters
UserIdentity$userThe user to get the option for
string$onameThe option to check
mixed | null$defaultOverrideA default value returned if the option does not exist
bool$ignoreHiddenWhether to ignore the effects of $wgHiddenPrefs
int$queryFlagsA bit field composed of READ_XXX flags
Returns
mixed|null User's current value for the option, Note that while option values retrieved from the database are always strings, default values and values set within the current request and not yet saved may be of another type.
See also
getBoolOption()
getIntOption()

Reimplemented from MediaWiki\User\Options\UserOptionsLookup.

Definition at line 36 of file StaticUserOptionsLookup.php.

◆ getOptions()

MediaWiki\User\Options\StaticUserOptionsLookup::getOptions ( UserIdentity $user,
int $flags = 0,
int $queryFlags = IDBAccessObject::READ_NORMAL )

Get all user's options.

Parameters
UserIdentity$userThe user to get the option for
int$flagsBitwise combination of: UserOptionsManager::EXCLUDE_DEFAULTS Exclude user options that are set to the default value. Options that are set to their conditionally default value are not excluded.
int$queryFlagsA bit field composed of READ_XXX flags
Returns
array

Reimplemented from MediaWiki\User\Options\UserOptionsLookup.

Definition at line 52 of file StaticUserOptionsLookup.php.

References MediaWiki\User\UserIdentity\getName().


The documentation for this class was generated from the following file: