MediaWiki  master
MediaWiki\Settings\SettingsBuilder Class Reference

Utility for loading settings files. More...

Collaboration diagram for MediaWiki\Settings\SettingsBuilder:

Public Member Functions

 __construct (string $baseDir, ExtensionRegistry $extensionRegistry, ConfigBuilder $configSink, PhpIniSink $phpIniSink, BagOStuff $cache=null)
 
 apply ()
 Apply any settings loaded so far to the runtime environment. More...
 
 finalize ()
 Settings can't be loaded & applied after calling this method. More...
 
 getDefaultConfig ()
 Return a Config object with all the default settings loaded so far. More...
 
 load (SettingsSource $source)
 Load settings from a SettingsSource. More...
 
 loadArray (array $newSettings)
 Load settings from an array. More...
 
 loadFile (string $path)
 Load settings from a file. More...
 
 validate ()
 Assert that the config loaded so far conforms the schema loaded so far. More...
 

Private Member Functions

 applySettings (array $settings)
 Apply the settings array. More...
 
 assertNotFinished ()
 
 loadRecursive (array $batch, array $stack=[])
 Loads all sources in the current batch, recursively resolving includes. More...
 
 makeSource ( $location)
 
 reset ()
 
 wrapSource (SettingsSource $source)
 

Private Attributes

string $baseDir
 
BagOStuff $cache
 
ConfigSchemaAggregator $configSchema
 
ConfigBuilder $configSink
 
SettingsSource[] $currentBatch
 
ExtensionRegistry $extensionRegistry
 
bool $finished = false
 When we're done applying all settings. More...
 
PhpIniSink $phpIniSink
 

Detailed Description

Utility for loading settings files.

Since
1.38

Definition at line 27 of file SettingsBuilder.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Settings\SettingsBuilder::__construct ( string  $baseDir,
ExtensionRegistry  $extensionRegistry,
ConfigBuilder  $configSink,
PhpIniSink  $phpIniSink,
BagOStuff  $cache = null 
)
Parameters
string$baseDir
ExtensionRegistry$extensionRegistry
ConfigBuilder$configSink
PhpIniSink$phpIniSink
BagOStuff | null$cacheBagOStuff used to cache settings loaded from each source. The caller should beware that secrets contained in any source passed to load or loadFile will be cached as well.

Definition at line 66 of file SettingsBuilder.php.

References MediaWiki\Settings\SettingsBuilder\$baseDir, MediaWiki\Settings\SettingsBuilder\$cache, MediaWiki\Settings\SettingsBuilder\$configSink, MediaWiki\Settings\SettingsBuilder\$extensionRegistry, MediaWiki\Settings\SettingsBuilder\$phpIniSink, and MediaWiki\Settings\SettingsBuilder\reset().

Member Function Documentation

◆ apply()

MediaWiki\Settings\SettingsBuilder::apply ( )

Apply any settings loaded so far to the runtime environment.

Stability: unstable
Note
This usually makes all configuration available in global variables. This may however not be the case in the future.
Returns
$this
Exceptions
SettingsBuilderException

Definition at line 203 of file SettingsBuilder.php.

References MediaWiki\Settings\SettingsBuilder\applySettings(), MediaWiki\Settings\SettingsBuilder\assertNotFinished(), MediaWiki\Settings\SettingsBuilder\loadRecursive(), and MediaWiki\Settings\SettingsBuilder\reset().

◆ applySettings()

MediaWiki\Settings\SettingsBuilder::applySettings ( array  $settings)
private

Apply the settings array.

Parameters
array$settings

Definition at line 269 of file SettingsBuilder.php.

References MediaWiki\$config, $ext, $path, and Config\get().

Referenced by MediaWiki\Settings\SettingsBuilder\apply().

◆ assertNotFinished()

MediaWiki\Settings\SettingsBuilder::assertNotFinished ( )
private

◆ finalize()

MediaWiki\Settings\SettingsBuilder::finalize ( )

Settings can't be loaded & applied after calling this method.

Access: internal
Most likely called only in Setup.php.
Returns
void

Definition at line 340 of file SettingsBuilder.php.

◆ getDefaultConfig()

MediaWiki\Settings\SettingsBuilder::getDefaultConfig ( )

Return a Config object with all the default settings loaded so far.

Returns
Config

Definition at line 188 of file SettingsBuilder.php.

◆ load()

MediaWiki\Settings\SettingsBuilder::load ( SettingsSource  $source)

Load settings from a SettingsSource.

Stability: unstable
Parameters
SettingsSource$source
Returns
$this

Definition at line 90 of file SettingsBuilder.php.

References MediaWiki\Settings\SettingsBuilder\assertNotFinished(), and MediaWiki\Settings\SettingsBuilder\wrapSource().

Referenced by MediaWiki\Settings\SettingsBuilder\loadArray(), and MediaWiki\Settings\SettingsBuilder\loadFile().

◆ loadArray()

MediaWiki\Settings\SettingsBuilder::loadArray ( array  $newSettings)

Load settings from an array.

Stability: unstable
Parameters
array$newSettings
Returns
$this

Definition at line 107 of file SettingsBuilder.php.

References MediaWiki\Settings\SettingsBuilder\load().

◆ loadFile()

MediaWiki\Settings\SettingsBuilder::loadFile ( string  $path)

Load settings from a file.

Stability: unstable
Parameters
string$path
Returns
$this

Definition at line 119 of file SettingsBuilder.php.

References MediaWiki\Settings\SettingsBuilder\load(), and MediaWiki\Settings\SettingsBuilder\makeSource().

◆ loadRecursive()

MediaWiki\Settings\SettingsBuilder::loadRecursive ( array  $batch,
array  $stack = [] 
)
private

Loads all sources in the current batch, recursively resolving includes.

Parameters
SettingsSource[]$batchThe batch of sources to load
string[]$stackThe current stack of includes, for cycle detection
Returns
array[] an array of settings arrays

Definition at line 227 of file SettingsBuilder.php.

References $source, and MediaWiki\Settings\SettingsBuilder\makeSource().

Referenced by MediaWiki\Settings\SettingsBuilder\apply().

◆ makeSource()

MediaWiki\Settings\SettingsBuilder::makeSource (   $location)
private

◆ reset()

MediaWiki\Settings\SettingsBuilder::reset ( )
private

◆ validate()

MediaWiki\Settings\SettingsBuilder::validate ( )

Assert that the config loaded so far conforms the schema loaded so far.

Note
this is slow, so you probably don't want to do this on every request.
Returns
StatusValue

Definition at line 155 of file SettingsBuilder.php.

References MediaWiki\$config, Config\get(), Config\has(), and StatusValue\newGood().

◆ wrapSource()

MediaWiki\Settings\SettingsBuilder::wrapSource ( SettingsSource  $source)
private
Parameters
SettingsSource$source
Returns
SettingsSource

Definition at line 128 of file SettingsBuilder.php.

References $source.

Referenced by MediaWiki\Settings\SettingsBuilder\load(), and MediaWiki\Settings\SettingsBuilder\makeSource().

Member Data Documentation

◆ $baseDir

string MediaWiki\Settings\SettingsBuilder::$baseDir
private

Definition at line 29 of file SettingsBuilder.php.

Referenced by MediaWiki\Settings\SettingsBuilder\__construct().

◆ $cache

BagOStuff MediaWiki\Settings\SettingsBuilder::$cache
private

Definition at line 35 of file SettingsBuilder.php.

Referenced by MediaWiki\Settings\SettingsBuilder\__construct().

◆ $configSchema

ConfigSchemaAggregator MediaWiki\Settings\SettingsBuilder::$configSchema
private

Definition at line 44 of file SettingsBuilder.php.

◆ $configSink

ConfigBuilder MediaWiki\Settings\SettingsBuilder::$configSink
private

Definition at line 38 of file SettingsBuilder.php.

Referenced by MediaWiki\Settings\SettingsBuilder\__construct().

◆ $currentBatch

SettingsSource [] MediaWiki\Settings\SettingsBuilder::$currentBatch
private

Definition at line 41 of file SettingsBuilder.php.

◆ $extensionRegistry

ExtensionRegistry MediaWiki\Settings\SettingsBuilder::$extensionRegistry
private

Definition at line 32 of file SettingsBuilder.php.

Referenced by MediaWiki\Settings\SettingsBuilder\__construct().

◆ $finished

bool MediaWiki\Settings\SettingsBuilder::$finished = false
private

When we're done applying all settings.

Definition at line 54 of file SettingsBuilder.php.

◆ $phpIniSink

PhpIniSink MediaWiki\Settings\SettingsBuilder::$phpIniSink
private

Definition at line 47 of file SettingsBuilder.php.

Referenced by MediaWiki\Settings\SettingsBuilder\__construct().


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