2021-11-09 17:29:14 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Settings\Config;
|
|
|
|
|
|
2021-11-16 20:41:38 +00:00
|
|
|
use Config;
|
2022-05-05 02:48:49 +00:00
|
|
|
use MediaWiki\Settings\SettingsBuilderException;
|
2021-11-11 17:50:14 +00:00
|
|
|
|
2021-11-09 17:29:14 +00:00
|
|
|
/**
|
2021-11-16 20:41:38 +00:00
|
|
|
* Builder for Config objects.
|
2021-11-09 17:29:14 +00:00
|
|
|
*
|
2022-05-04 14:52:01 +00:00
|
|
|
* @unstable
|
2021-11-09 17:29:14 +00:00
|
|
|
*/
|
2021-11-16 20:41:38 +00:00
|
|
|
interface ConfigBuilder {
|
2021-11-09 17:29:14 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the configuration $key to $value.
|
|
|
|
|
*
|
|
|
|
|
* @param string $key
|
|
|
|
|
* @param mixed $value
|
2021-11-11 17:50:14 +00:00
|
|
|
* @param MergeStrategy|null $mergeStrategy strategy for merging array config values.
|
2021-11-16 20:41:38 +00:00
|
|
|
* @return ConfigBuilder
|
2021-11-09 17:29:14 +00:00
|
|
|
*/
|
2021-11-16 20:41:38 +00:00
|
|
|
public function set( string $key, $value, MergeStrategy $mergeStrategy = null ): ConfigBuilder;
|
2021-11-09 17:29:14 +00:00
|
|
|
|
2022-05-04 14:52:01 +00:00
|
|
|
/**
|
2022-05-05 02:48:49 +00:00
|
|
|
* Set all values in the array.
|
2022-05-04 14:52:01 +00:00
|
|
|
*
|
|
|
|
|
* @param array $values
|
2022-05-05 02:48:49 +00:00
|
|
|
* @param MergeStrategy[] $mergeStrategies The merge strategies indexed by config key
|
2022-05-04 14:52:01 +00:00
|
|
|
* @return ConfigBuilder
|
|
|
|
|
*/
|
2022-05-05 02:48:49 +00:00
|
|
|
public function setMulti( array $values, array $mergeStrategies = [] ): ConfigBuilder;
|
2022-05-04 14:52:01 +00:00
|
|
|
|
2021-11-09 17:29:14 +00:00
|
|
|
/**
|
2021-11-11 17:50:14 +00:00
|
|
|
* Set the default for the configuration $key to $defaultValue.
|
|
|
|
|
*
|
|
|
|
|
* If the $key is already set, non-array $defaultValue will be ignored,
|
|
|
|
|
* for array $defaultValue the existing value will be merged into it as
|
|
|
|
|
* if the default was already there when the existing value was set.
|
2021-11-09 17:29:14 +00:00
|
|
|
*
|
|
|
|
|
* @param string $key
|
2021-11-11 17:50:14 +00:00
|
|
|
* @param mixed $defaultValue
|
|
|
|
|
* @param MergeStrategy|null $mergeStrategy strategy for merging array config values.
|
2021-11-16 20:41:38 +00:00
|
|
|
* @return ConfigBuilder
|
2021-11-09 17:29:14 +00:00
|
|
|
*/
|
2021-11-16 20:41:38 +00:00
|
|
|
public function setDefault( string $key, $defaultValue, MergeStrategy $mergeStrategy = null ): ConfigBuilder;
|
2021-11-09 17:29:14 +00:00
|
|
|
|
2022-05-05 02:48:49 +00:00
|
|
|
/**
|
|
|
|
|
* Set defaults in a batch.
|
|
|
|
|
*
|
|
|
|
|
* @param array $defaults The default values
|
|
|
|
|
* @param MergeStrategy[] $mergeStrategies The merge strategies indexed by config key
|
|
|
|
|
* @return ConfigBuilder
|
|
|
|
|
* @throws SettingsBuilderException if a merge strategy is not provided and
|
|
|
|
|
* the value is not an array.
|
|
|
|
|
*/
|
|
|
|
|
public function setMultiDefault( array $defaults, array $mergeStrategies ): ConfigBuilder;
|
|
|
|
|
|
2021-11-16 20:41:38 +00:00
|
|
|
/**
|
|
|
|
|
* Build the resulting Config object.
|
|
|
|
|
*
|
|
|
|
|
* @return Config
|
|
|
|
|
*/
|
|
|
|
|
public function build(): Config;
|
2021-11-09 17:29:14 +00:00
|
|
|
}
|