MediaWiki  master
MediaWiki\Settings\Config\ConfigSchemaAggregator Class Reference

Aggregates multiple config schemas. More...

Inheritance diagram for MediaWiki\Settings\Config\ConfigSchemaAggregator:
Collaboration diagram for MediaWiki\Settings\Config\ConfigSchemaAggregator:

Public Member Functions

 addDefaults (array $defaults, string $sourceName='unknown')
 Declare default values. More...
 
 addMergeStrategies (array $mergeStrategies, string $sourceName='unknown')
 Declare merge strategies. More...
 
 addSchema (string $key, array $schema, string $sourceName='unknown')
 Add a config schema to the aggregator. More...
 
 addTypes (array $types, string $sourceName='unknown')
 Declare types. More...
 
 getDefaultFor (string $key)
 Get default value for the $key. More...
 
 getDefaults ()
 Get all defined default values. More...
 
 getDefinedKeys ()
 Get a list of all defined keys. More...
 
 getMergeStrategies ()
 Get all merge strategies indexed by config key. More...
 
 getMergeStrategyFor (string $key)
 Get the merge strategy defined for the $key, or null if none defined. More...
 
 getMergeStrategyNames ()
 Get the names of all known merge strategies. More...
 
 getSchemaFor (string $key)
 Get the schema for the given key. More...
 
 getTypeFor (string $key)
 Get type for the $key, or null if the type is not known. More...
 
 getTypes ()
 Get all known types. More...
 
 hasDefaultFor (string $key)
 Check if the $key has a default values set in the schema. More...
 
 hasSchemaFor (string $key)
 Check whether schema for $key is defined. More...
 
 validateConfig (Config $config)
 Check if the given config conforms to the schema. More...
 
 validateValue (string $key, $value)
 Check if the given value conforms to the relevant schema. More...
 

Private Member Functions

 hasNumericKeys (array $value)
 
 initMergeStrategies ()
 Initialise $this->mergeStrategyCache. More...
 
 mergeListInternal ( $values, &$target, $fieldName, $sourceName)
 Update a map with the given values. More...
 
 setListValueInternal ( $schema, &$target, $key, $fieldName, $sourceName)
 Update a map with a specific field. More...
 

Static Private Member Functions

static getStrategyForType ( $type)
 Returns an appropriate merge strategy for the given type. More...
 

Private Attributes

array $defaults = []
 Map of config keys to default values, for optimized access. More...
 
array $mergeStrategies = []
 Map of config keys to merge strategies, for optimized access. More...
 
MergeStrategy[] null $mergeStrategyCache
 
array[] $schemas = []
 Maps config keys to JSON schema structures. More...
 
array $types = []
 Map of config keys to types, for optimized access. More...
 
Validator $validator
 

Detailed Description

Aggregates multiple config schemas.

Some aspects of the schema are maintained separately, to optimized for settings defaults, types and merge strategies in bulk, and later accessing them independently of each other, for each config key.

Definition at line 20 of file ConfigSchemaAggregator.php.

Member Function Documentation

◆ addDefaults()

MediaWiki\Settings\Config\ConfigSchemaAggregator::addDefaults ( array  $defaults,
string  $sourceName = 'unknown' 
)

Declare default values.

Parameters
array$defaults
string$sourceName

Definition at line 126 of file ConfigSchemaAggregator.php.

References MediaWiki\Settings\Config\ConfigSchemaAggregator\mergeListInternal().

◆ addMergeStrategies()

MediaWiki\Settings\Config\ConfigSchemaAggregator::addMergeStrategies ( array  $mergeStrategies,
string  $sourceName = 'unknown' 
)

Declare merge strategies.

Parameters
array$mergeStrategies
string$sourceName

Definition at line 146 of file ConfigSchemaAggregator.php.

References MediaWiki\Settings\Config\ConfigSchemaAggregator\mergeListInternal().

◆ addSchema()

MediaWiki\Settings\Config\ConfigSchemaAggregator::addSchema ( string  $key,
array  $schema,
string  $sourceName = 'unknown' 
)

Add a config schema to the aggregator.

Parameters
string$key
array$schema
string$sourceName

Definition at line 48 of file ConfigSchemaAggregator.php.

References MediaWiki\Settings\Config\ConfigSchemaAggregator\setListValueInternal().

◆ addTypes()

MediaWiki\Settings\Config\ConfigSchemaAggregator::addTypes ( array  $types,
string  $sourceName = 'unknown' 
)

Declare types.

Parameters
array$types
string$sourceName

Definition at line 136 of file ConfigSchemaAggregator.php.

References MediaWiki\Settings\Config\ConfigSchemaAggregator\mergeListInternal().

◆ getDefaultFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getDefaultFor ( string  $key)

Get default value for the $key.

For keys that do not define a default, null is assumed.

Parameters
string$key
Returns
mixed

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 251 of file ConfigSchemaAggregator.php.

◆ getDefaults()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getDefaults ( )

Get all defined default values.

Returns
array

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 212 of file ConfigSchemaAggregator.php.

◆ getDefinedKeys()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getDefinedKeys ( )

Get a list of all defined keys.

Returns
string[]

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 163 of file ConfigSchemaAggregator.php.

◆ getMergeStrategies()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getMergeStrategies ( )

Get all merge strategies indexed by config key.

If there is no merge strategy for a given key, the element will be absent.

Returns
MergeStrategy[]

Definition at line 285 of file ConfigSchemaAggregator.php.

◆ getMergeStrategyFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getMergeStrategyFor ( string  $key)

Get the merge strategy defined for the $key, or null if none defined.

Parameters
string$key
Returns
MergeStrategy|null
Exceptions
SettingsBuilderExceptionif merge strategy name is invalid.

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 272 of file ConfigSchemaAggregator.php.

◆ getMergeStrategyNames()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getMergeStrategyNames ( )

Get the names of all known merge strategies.

Returns
array<string>

Definition at line 230 of file ConfigSchemaAggregator.php.

◆ getSchemaFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getSchemaFor ( string  $key)

Get the schema for the given key.

Parameters
string$key
Returns
array

Definition at line 176 of file ConfigSchemaAggregator.php.

◆ getStrategyForType()

static MediaWiki\Settings\Config\ConfigSchemaAggregator::getStrategyForType (   $type)
staticprivate

Returns an appropriate merge strategy for the given type.

Parameters
string | array$type
Returns
string

Definition at line 332 of file ConfigSchemaAggregator.php.

References $type.

◆ getTypeFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getTypeFor ( string  $key)

Get type for the $key, or null if the type is not known.

Parameters
string$key
Returns
mixed

Definition at line 261 of file ConfigSchemaAggregator.php.

◆ getTypes()

MediaWiki\Settings\Config\ConfigSchemaAggregator::getTypes ( )

Get all known types.

Returns
array<string|array>

Definition at line 221 of file ConfigSchemaAggregator.php.

◆ hasDefaultFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::hasDefaultFor ( string  $key)

Check if the $key has a default values set in the schema.

Parameters
string$key
Returns
bool

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 240 of file ConfigSchemaAggregator.php.

◆ hasNumericKeys()

MediaWiki\Settings\Config\ConfigSchemaAggregator::hasNumericKeys ( array  $value)
private
Parameters
array$value
Returns
bool

Definition at line 448 of file ConfigSchemaAggregator.php.

◆ hasSchemaFor()

MediaWiki\Settings\Config\ConfigSchemaAggregator::hasSchemaFor ( string  $key)

Check whether schema for $key is defined.

Parameters
string$key
Returns
bool

Implements MediaWiki\Settings\Config\ConfigSchema.

Definition at line 200 of file ConfigSchemaAggregator.php.

◆ initMergeStrategies()

MediaWiki\Settings\Config\ConfigSchemaAggregator::initMergeStrategies ( )
private

Initialise $this->mergeStrategyCache.

Definition at line 295 of file ConfigSchemaAggregator.php.

References $type.

◆ mergeListInternal()

MediaWiki\Settings\Config\ConfigSchemaAggregator::mergeListInternal (   $values,
$target,
  $fieldName,
  $sourceName 
)
private

Update a map with the given values.

Parameters
array$values
array&$target
string$fieldName
string$sourceName
Exceptions
SettingsBuilderExceptionif a conflict is detected
Returns
void

Definition at line 106 of file ConfigSchemaAggregator.php.

Referenced by MediaWiki\Settings\Config\ConfigSchemaAggregator\addDefaults(), MediaWiki\Settings\Config\ConfigSchemaAggregator\addMergeStrategies(), and MediaWiki\Settings\Config\ConfigSchemaAggregator\addTypes().

◆ setListValueInternal()

MediaWiki\Settings\Config\ConfigSchemaAggregator::setListValueInternal (   $schema,
$target,
  $key,
  $fieldName,
  $sourceName 
)
private

Update a map with a specific field.

Parameters
array$schema
array&$target
string$key
string$fieldName
string$sourceName
Returns
void
Exceptions
SettingsBuilderExceptionif a conflict is detected

Definition at line 79 of file ConfigSchemaAggregator.php.

Referenced by MediaWiki\Settings\Config\ConfigSchemaAggregator\addSchema().

◆ validateConfig()

MediaWiki\Settings\Config\ConfigSchemaAggregator::validateConfig ( Config  $config)

Check if the given config conforms to the schema.

Note that all keys for which a schema was defined are required to be present in $config.

Parameters
Config$config
Returns
StatusValue

Definition at line 362 of file ConfigSchemaAggregator.php.

References StatusValue\fatal(), Config\get(), and Config\has().

◆ validateValue()

MediaWiki\Settings\Config\ConfigSchemaAggregator::validateValue ( string  $key,
  $value 
)

Check if the given value conforms to the relevant schema.

Parameters
string$key
mixed$value
Returns
StatusValue

Definition at line 386 of file ConfigSchemaAggregator.php.

Member Data Documentation

◆ $defaults

array MediaWiki\Settings\Config\ConfigSchemaAggregator::$defaults = []
private

Map of config keys to default values, for optimized access.

Definition at line 27 of file ConfigSchemaAggregator.php.

◆ $mergeStrategies

array MediaWiki\Settings\Config\ConfigSchemaAggregator::$mergeStrategies = []
private

Map of config keys to merge strategies, for optimized access.

Definition at line 33 of file ConfigSchemaAggregator.php.

◆ $mergeStrategyCache

MergeStrategy [] null MediaWiki\Settings\Config\ConfigSchemaAggregator::$mergeStrategyCache
private

Definition at line 39 of file ConfigSchemaAggregator.php.

◆ $schemas

array [] MediaWiki\Settings\Config\ConfigSchemaAggregator::$schemas = []
private

Maps config keys to JSON schema structures.

Definition at line 24 of file ConfigSchemaAggregator.php.

◆ $types

array MediaWiki\Settings\Config\ConfigSchemaAggregator::$types = []
private

Map of config keys to types, for optimized access.

Definition at line 30 of file ConfigSchemaAggregator.php.

◆ $validator

Validator MediaWiki\Settings\Config\ConfigSchemaAggregator::$validator
private

Definition at line 36 of file ConfigSchemaAggregator.php.


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