MediaWiki master
MediaWiki\User\Options\DefaultOptionsLookup Class Reference

A service class to control default user options. More...

Inherits MediaWiki\User\Options\UserOptionsLookup.

Collaboration diagram for MediaWiki\User\Options\DefaultOptionsLookup:

Public Member Functions

 __construct (ServiceOptions $options, LanguageCode $contentLang, HookContainer $hookContainer, NamespaceInfo $nsInfo, ConditionalDefaultsLookup $conditionalUserOptionsDefaultsLookup, UserIdentityLookup $userIdentityLookup, UserNameUtils $userNameUtils)
 
 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()

 
 getOptionBatchForUserNames (array $users, string $key)
 Get a single option for a batch of users, given their names.
 
 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
 __construct (UserNameUtils $userNameUtils)
 
 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.
 
 isOptionGlobal (UserIdentity $user, string $key)
 Determine if a user option came from a source other than the local store or the defaults.
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 
- Public Attributes inherited from MediaWiki\User\Options\UserOptionsLookup
const EXCLUDE_DEFAULTS = 1
 Exclude user options that are set to their default value.
 
const LOCAL_EXCEPTION_SUFFIX = '-local-exception'
 The suffix appended to preference names for the associated preference that tracks whether they have a local override.
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWiki\User\Options\UserOptionsLookup
 getCacheKey (UserIdentity $user)
 Get a cache key for a user.
 

Detailed Description

A service class to control default user options.

Since
1.35

Definition at line 41 of file DefaultOptionsLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\Options\DefaultOptionsLookup::__construct ( ServiceOptions $options,
LanguageCode $contentLang,
HookContainer $hookContainer,
NamespaceInfo $nsInfo,
ConditionalDefaultsLookup $conditionalUserOptionsDefaultsLookup,
UserIdentityLookup $userIdentityLookup,
UserNameUtils $userNameUtils )
Parameters
ServiceOptions$options
LanguageCode$contentLang
HookContainer$hookContainer
NamespaceInfo$nsInfo
ConditionalDefaultsLookup$conditionalUserOptionsDefaultsLookup
UserIdentityLookup$userIdentityLookup
UserNameUtils$userNameUtils

Definition at line 75 of file DefaultOptionsLookup.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ getDefaultOptions()

MediaWiki\User\Options\DefaultOptionsLookup::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 135 of file DefaultOptionsLookup.php.

References getCacheKey().

◆ getOption()

MediaWiki\User\Options\DefaultOptionsLookup::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 162 of file DefaultOptionsLookup.php.

◆ getOptionBatchForUserNames()

MediaWiki\User\Options\DefaultOptionsLookup::getOptionBatchForUserNames ( array $users,
string $key )

Get a single option for a batch of users, given their names.

Results are uncached. Use getOption() to get options with a per-user cache.

User names are used because that's what GenderCache has. If you're calling this and you're not GenderCache, consider adding a method taking an array of UserIdentity objects instead.

Since
1.44
Parameters
string[]$usersA normalized list of usernames
string$keyThe option to get
Returns
array The option values, indexed by the provided usernames

Reimplemented from MediaWiki\User\Options\UserOptionsLookup.

Definition at line 209 of file DefaultOptionsLookup.php.

◆ getOptions()

MediaWiki\User\Options\DefaultOptionsLookup::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 176 of file DefaultOptionsLookup.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\User\Options\DefaultOptionsLookup::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const DefaultUserOptions
Name constant for the DefaultUserOptions setting, for use with Config::get()
const DefaultSkin
Name constant for the DefaultSkin setting, for use with Config::get()
const NamespacesToBeSearchedDefault
Name constant for the NamespacesToBeSearchedDefault setting, for use with Config::get()
Access: internal
For use by ServiceWiring

Definition at line 46 of file DefaultOptionsLookup.php.


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