31use Wikimedia\Assert\Assert;
49 private $serviceOptions;
58 private $defaultOptions =
null;
76 $this->serviceOptions = $options;
77 $this->contentLang = $contentLang;
78 $this->hookRunner =
new HookRunner( $hookContainer );
86 if ( $this->defaultOptions !== null ) {
87 return $this->defaultOptions;
95 $contentLangCode = $this->contentLang->getCode();
96 $LangsWithStaticDefaultVariant = LanguageConverter::$languagesWithStaticDefaultVariant;
97 $staticDefaultVariant = $LangsWithStaticDefaultVariant[$contentLangCode] ?? $contentLangCode;
98 $this->defaultOptions[
'language'] = $contentLangCode;
99 $this->defaultOptions[
'variant'] = $staticDefaultVariant;
100 foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
101 $staticDefaultVariant = $LangsWithStaticDefaultVariant[$langCode] ?? $langCode;
102 $this->defaultOptions[
"variant-$langCode"] = $staticDefaultVariant;
109 foreach ( $this->nsInfo->getValidNamespaces() as $n ) {
110 $this->defaultOptions[
'searchNs' . $n] = ( $nsSearchDefault[$n] ?? false ) ? 1 : 0;
115 $this->hookRunner->onUserGetDefaultOptions( $this->defaultOptions );
117 return $this->defaultOptions;
126 $defaultOverride =
null,
127 bool $ignoreHidden =
false,
128 int $queryFlags = self::READ_NORMAL
130 $this->verifyUsable( $user, __METHOD__ );
131 return $this->getDefaultOption( $oname ) ?? $defaultOverride;
140 int $queryFlags = self::READ_NORMAL
142 $this->verifyUsable( $user, __METHOD__ );
143 if ( $flags & self::EXCLUDE_DEFAULTS ) {
146 return $this->getDefaultOptions();
157 private function verifyUsable(
UserIdentity $user,
string $fname ) {
158 Assert::precondition( !$user->
isRegistered(),
"$fname called on a registered user " );
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Base class for multi-variant language conversion.
Base class for language-specific code.
A class containing constants representing the names of configuration variables.
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()
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
The main skin class which provides methods and properties for all other skins.
static normalizeKey( $key)
Normalize a skin preference value to a form that can be loaded.