MediaWiki REL1_35
MediaWiki\User\DefaultOptionsLookup Class Reference

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

Inheritance diagram for MediaWiki\User\DefaultOptionsLookup:
Collaboration diagram for MediaWiki\User\DefaultOptionsLookup:

Public Member Functions

 __construct (ServiceOptions $options, Language $contentLang, HookContainer $hookContainer)
 
 getDefaultOption (string $opt)
 Get a given default option value.
Parameters
string$optName of option to retrieve
Returns
string|null Default option value

 
 getDefaultOptions ()
 Combine the language default options with any site-specific options and add the default language variants.
Returns
array Array of String options

 
 getOption (UserIdentity $user, string $oname, $defaultOverride=null, bool $ignoreHidden=false, int $queryFlags=self::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
See also
getBoolOption()
getIntOption()

 
 getOptions (UserIdentity $user, int $flags=0, int $queryFlags=self::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.
int$queryFlagsA bit field composed of READ_XXX flags
Returns
array

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

Public Attributes

const CONSTRUCTOR_OPTIONS
 
- Public Attributes inherited from MediaWiki\User\UserOptionsLookup
const EXCLUDE_DEFAULTS = 1
 Exclude user options that are set to their default value.
 
- Public Attributes inherited from IDBAccessObject
const READ_LOCKING = self::READ_LATEST | 2
 Constants for object loading bitfield flags (higher => higher QoS)
 
const READ_NONE = -1
 

Private Member Functions

 verifyUsable (UserIdentity $user, string $fname)
 Checks if the DefaultOptionsLookup is usable as an instance of UserOptionsLookup.
 

Private Attributes

Language $contentLang
 
array null $defaultOptions = null
 Cached default options.
 
HookRunner $hookRunner
 
ServiceOptions $serviceOptions
 

Detailed Description

A service class to control default user options.

Since
1.35

Definition at line 35 of file DefaultOptionsLookup.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\User\DefaultOptionsLookup::__construct ( ServiceOptions  $options,
Language  $contentLang,
HookContainer  $hookContainer 
)
Parameters
ServiceOptions$options
Language$contentLang
HookContainer$hookContainer

Definition at line 60 of file DefaultOptionsLookup.php.

References MediaWiki\User\DefaultOptionsLookup\$contentLang, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ getDefaultOption()

MediaWiki\User\DefaultOptionsLookup::getDefaultOption ( string  $opt)

Get a given default option value.

Parameters
string$optName of option to retrieve
Returns
string|null Default option value

Reimplemented from MediaWiki\User\UserOptionsLookup.

Definition at line 107 of file DefaultOptionsLookup.php.

◆ getDefaultOptions()

MediaWiki\User\DefaultOptionsLookup::getDefaultOptions ( )

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

Returns
array Array of String options

Reimplemented from MediaWiki\User\UserOptionsLookup.

Definition at line 74 of file DefaultOptionsLookup.php.

References MediaWiki\User\DefaultOptionsLookup\$defaultOptions.

◆ getOption()

MediaWiki\User\DefaultOptionsLookup::getOption ( UserIdentity  $user,
string  $oname,
  $defaultOverride = null,
bool  $ignoreHidden = false,
int  $queryFlags = self::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
See also
getBoolOption()
getIntOption()

Reimplemented from MediaWiki\User\UserOptionsLookup.

Definition at line 115 of file DefaultOptionsLookup.php.

◆ getOptions()

MediaWiki\User\DefaultOptionsLookup::getOptions ( UserIdentity  $user,
int  $flags = 0,
int  $queryFlags = self::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.
int$queryFlagsA bit field composed of READ_XXX flags
Returns
array

Reimplemented from MediaWiki\User\UserOptionsLookup.

Definition at line 129 of file DefaultOptionsLookup.php.

◆ verifyUsable()

MediaWiki\User\DefaultOptionsLookup::verifyUsable ( UserIdentity  $user,
string  $fname 
)
private

Checks if the DefaultOptionsLookup is usable as an instance of UserOptionsLookup.

It only makes sense in an installer context when UserOptionsManager cannot be yet instantiated as the database is not available. Thus, this can only be called for an anon user, calling under different circumstances indicates a bug.

Parameters
UserIdentity$user
string$fname

Definition at line 149 of file DefaultOptionsLookup.php.

References MediaWiki\User\UserIdentity\isRegistered().

Member Data Documentation

◆ $contentLang

Language MediaWiki\User\DefaultOptionsLookup::$contentLang
private

◆ $defaultOptions

array null MediaWiki\User\DefaultOptionsLookup::$defaultOptions = null
private

Cached default options.

Definition at line 50 of file DefaultOptionsLookup.php.

Referenced by MediaWiki\User\DefaultOptionsLookup\getDefaultOptions().

◆ $hookRunner

HookRunner MediaWiki\User\DefaultOptionsLookup::$hookRunner
private

Definition at line 53 of file DefaultOptionsLookup.php.

◆ $serviceOptions

ServiceOptions MediaWiki\User\DefaultOptionsLookup::$serviceOptions
private

Definition at line 44 of file DefaultOptionsLookup.php.

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\User\DefaultOptionsLookup::CONSTRUCTOR_OPTIONS
Initial value:
= [
'DefaultSkin',
'DefaultUserOptions',
'NamespacesToBeSearchedDefault'
]

Definition at line 37 of file DefaultOptionsLookup.php.


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