wiki.techinc.nl/includes/Settings/Config/ConfigSchema.php
Aryeh Gregor b72b9a8c43 Move dynamic defaults into MainConfigSchema
The goal is to keep the actual default values for settings in the same
place as the setting is declared, and applied using the regular means
for loading the settings -- not in a separate piece of code that needs
to be loaded through some entirely different mechanism.

SetupDynamicConfig.php now contains a few categories of things:

* Post-processing of configuration settings, where already-set settings
  are altered. This could be moved to MainConfigSchema too as a separate
  set of methods.
* Processing of old aliases of settings (blacklist, slave) that are not
  registered as settings anymore and therefore are not available to
  MainConfigSchema. This could perhaps be moved to LocalSettings
  processing somehow?
* Setting $wgUseEnotif, which is also not registered as a setting.
  Easiest would be just to declare it as a setting and have it set
  unconditionally.
* Setting the actual timezone to $wgLocaltimezone. This is not related
  to configuration and should just be in Setup.php.

Bug: T305093
Change-Id: Ia5c23b52dbbfcb3d07ffcf5d3b7f2d7befba2a26
2022-07-07 09:55:48 +10:00

73 lines
1.5 KiB
PHP

<?php
namespace MediaWiki\Settings\Config;
use MediaWiki\Settings\SettingsBuilderException;
/**
* Represents a config schema.
*
* @since 1.39
*/
interface ConfigSchema {
/**
* Get a list of all defined keys
*
* @return string[]
*/
public function getDefinedKeys(): array;
/**
* Check whether schema for $key is defined.
*
* @param string $key
*
* @return bool
*/
public function hasSchemaFor( string $key ): bool;
/**
* Get all defined default values.
*
* @return array<string,mixed> An associative array mapping setting names
* to their respective default values.
*/
public function getDefaults(): array;
/**
* Get all dynamic default declarations.
* @see DynamicDefaultValues.
*
* @return array<string,array>
*/
public function getDynamicDefaults(): array;
/**
* Check if the $key has a default value set in the schema.
*
* @param string $key
*
* @return bool
*/
public function hasDefaultFor( string $key ): bool;
/**
* Get the default value for the $key.
* For keys that do not define a default, null is assumed.
*
* @param string $key
*
* @return mixed
*/
public function getDefaultFor( string $key );
/**
* Get the merge strategy defined for the $key, or null if none defined.
*
* @param string $key
*
* @return MergeStrategy|null
* @throws SettingsBuilderException if merge strategy name is invalid.
*/
public function getMergeStrategyFor( string $key ): ?MergeStrategy;
}