MediaWiki REL1_34
MediaWiki\Config\ConfigRepository Class Reference

Object which holds currently registered configuration options. More...

Inheritance diagram for MediaWiki\Config\ConfigRepository:
Collaboration diagram for MediaWiki\Config\ConfigRepository:

Public Member Functions

 __construct (\ConfigFactory $configFactory)
 
 add ( $name, array $config)
 Adds the definition of a configuration to this repository.
 
 get ( $name)
 Returns the ConfigItem with the given name, if there's one.
 
 getAll ()
 Returns an array of all configuration items saved in this ConfigRepository.
 
 getDescriptionOf ( $name)
 Returns the description of the given config option, This can be either a localized description, if one such, or the (maybe english only) description provided in the definition of the configuration.
 
 getPublic ()
 Returns an array of all public configuration options saved in this ConfigRepository.
 
 getValueOf ( $name)
 Returns the current value of the configuration option.
 
 has ( $name, $alsoPrivate=false)
 Returns true, if this repository contains a configuration with a specific name.
 
 isEmpty ( $includePrivate=false)
 Returns true, if there're no elements in this instance, otherwise false.
 
 salvage (SalvageableService $other)
 Re-uses existing Cache objects from $other.
 

Private Attributes

ConfigFactory $configFactory
 
array $configItems
 

Detailed Description

Object which holds currently registered configuration options.

Since
1.32

Definition at line 33 of file ConfigRepository.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Config\ConfigRepository::__construct ( \ConfigFactory $configFactory)
Parameters
\\ConfigFactory$configFactory

Definition at line 46 of file ConfigRepository.php.

References MediaWiki\Config\ConfigRepository\$configFactory.

Member Function Documentation

◆ add()

MediaWiki\Config\ConfigRepository::add ( $name,
array $config )

Adds the definition of a configuration to this repository.

Parameters
string$namethe name of the config
array$configOptions of this config. Values are:
  • value: The default value of this configuration, required
  • providedby: The name of the provider of this config (an extension, core, ...), required
  • configregistry: The name of the config to retrieve the value with, required
  • public: whether this option is public or not, if not set, the option is considered as "private", optional
  • description: the not localized description of this config option, optional
  • descriptionmsg: The message key of the localized description of this configuration option, optional
Exceptions

\ConfigException

Definition at line 152 of file ConfigRepository.php.

References MediaWiki\Config\ConfigRepository\has().

Referenced by MediaWiki\Config\ConfigRepository\salvage().

◆ get()

MediaWiki\Config\ConfigRepository::get ( $name)

Returns the ConfigItem with the given name, if there's one.

Throws a ConfigException otherwise.

Parameters
string$nameThe name of the configuration option to get
Returns
array
Exceptions

\ConfigException

Definition at line 70 of file ConfigRepository.php.

References MediaWiki\Config\ConfigRepository\has().

◆ getAll()

MediaWiki\Config\ConfigRepository::getAll ( )

Returns an array of all configuration items saved in this ConfigRepository.

This includes all configuration options, including the ones marked as private and public.

Note: This function does not do any permission checks or something similar. You should not use this function, if the output will be available to the public audience! Use ConfigRepository::getPublic() instead.

Returns
array

Definition at line 88 of file ConfigRepository.php.

◆ getDescriptionOf()

MediaWiki\Config\ConfigRepository::getDescriptionOf ( $name)

Returns the description of the given config option, This can be either a localized description, if one such, or the (maybe english only) description provided in the definition of the configuration.

If both is not provided an empty string is returned.

Parameters
string$nameThe name of the configuration option to get the description of
Returns
string HTML-escaped string

Definition at line 126 of file ConfigRepository.php.

References wfMessage().

◆ getPublic()

MediaWiki\Config\ConfigRepository::getPublic ( )

Returns an array of all public configuration options saved in this ConfigRepository.

Returns
array

Definition at line 97 of file ConfigRepository.php.

◆ getValueOf()

MediaWiki\Config\ConfigRepository::getValueOf ( $name)

Returns the current value of the configuration option.

If no ConfigRegistry was provided when the config was added to the repository, the default value will be returned.

Parameters
string$nameThe name of the configuration option to get the value of
Returns
mixed
Exceptions

\ConfigException

Definition at line 109 of file ConfigRepository.php.

◆ has()

MediaWiki\Config\ConfigRepository::has ( $name,
$alsoPrivate = false )

Returns true, if this repository contains a configuration with a specific name.

Parameters
string$nameThe name of the config to check the existence of
bool$alsoPrivateIf set to true, will check the private config options, too
Returns
bool

Definition at line 57 of file ConfigRepository.php.

Referenced by MediaWiki\Config\ConfigRepository\add(), and MediaWiki\Config\ConfigRepository\get().

◆ isEmpty()

MediaWiki\Config\ConfigRepository::isEmpty ( $includePrivate = false)

Returns true, if there're no elements in this instance, otherwise false.

Parameters
bool$includePrivateWhether configuration options, that are marked as private should be included in this check.
Returns
bool

Definition at line 172 of file ConfigRepository.php.

◆ salvage()

MediaWiki\Config\ConfigRepository::salvage ( SalvageableService $other)

Re-uses existing Cache objects from $other.

Cache objects are only re-used if the registered factory function for both is the same.

See also
SalvageableService::salvage()
Parameters
SalvageableService$otherThe object to salvage state from. $other must have the exact same type as $this.

Implements Wikimedia\Services\SalvageableService.

Definition at line 189 of file ConfigRepository.php.

References MediaWiki\Config\ConfigRepository\add().

Member Data Documentation

◆ $configFactory

ConfigFactory MediaWiki\Config\ConfigRepository::$configFactory
private

Definition at line 35 of file ConfigRepository.php.

Referenced by MediaWiki\Config\ConfigRepository\__construct().

◆ $configItems

array MediaWiki\Config\ConfigRepository::$configItems
private
Initial value:
= [
'private' => [],
'public' => [],
]

Definition at line 38 of file ConfigRepository.php.


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