MediaWiki  master
UserOptionsLookup.php
Go to the documentation of this file.
1 <?php
21 namespace MediaWiki\User;
22 
23 use IDBAccessObject;
24 
29 abstract class UserOptionsLookup implements IDBAccessObject {
30 
34  public const EXCLUDE_DEFAULTS = 1;
35 
42  abstract public function getDefaultOptions(): array;
43 
50  abstract public function getDefaultOption( string $opt );
51 
64  abstract public function getOption(
65  UserIdentity $user,
66  string $oname,
67  $defaultOverride = null,
68  bool $ignoreHidden = false,
69  int $queryFlags = self::READ_NORMAL
70  );
71 
82  abstract public function getOptions(
83  UserIdentity $user,
84  int $flags = 0,
85  int $queryFlags = self::READ_NORMAL
86  ): array;
87 
97  public function getBoolOption(
98  UserIdentity $user,
99  string $oname,
100  int $queryFlags = self::READ_NORMAL
101  ): bool {
102  return (bool)$this->getOption(
103  $user, $oname, null, false, $queryFlags );
104  }
105 
116  public function getIntOption(
117  UserIdentity $user,
118  string $oname,
119  int $defaultOverride = 0,
120  int $queryFlags = self::READ_NORMAL
121  ): int {
122  $val = $this->getOption(
123  $user, $oname, $defaultOverride, false, $queryFlags );
124  if ( $val == '' ) {
125  $val = $defaultOverride;
126  }
127  return intval( $val );
128  }
129 }
MediaWiki\User\UserOptionsLookup\getOptions
getOptions(UserIdentity $user, int $flags=0, int $queryFlags=self::READ_NORMAL)
Get all user's options.
MediaWiki\User\UserOptionsLookup\EXCLUDE_DEFAULTS
const EXCLUDE_DEFAULTS
Exclude user options that are set to their default value.
Definition: UserOptionsLookup.php:34
MediaWiki\User\UserOptionsLookup\getIntOption
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.
Definition: UserOptionsLookup.php:116
IDBAccessObject
Interface for database access objects.
Definition: IDBAccessObject.php:57
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:32
MediaWiki\User\UserOptionsLookup\getOption
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.
MediaWiki\User\UserOptionsLookup\getDefaultOption
getDefaultOption(string $opt)
Get a given default option value.
MediaWiki\User
Definition: DefaultOptionsLookup.php:21
MediaWiki\User\UserOptionsLookup\getBoolOption
getBoolOption(UserIdentity $user, string $oname, int $queryFlags=self::READ_NORMAL)
Get the user's current setting for a given option, as a boolean value.
Definition: UserOptionsLookup.php:97
MediaWiki\User\UserOptionsLookup
Provides access to user options.
Definition: UserOptionsLookup.php:29
MediaWiki\User\UserOptionsLookup\getDefaultOptions
getDefaultOptions()
Combine the language default options with any site-specific options and add the default language vari...