MediaWiki  1.28.0
ConfigFactory Class Reference

Factory class to create Config objects. More...

Inheritance diagram for ConfigFactory:
Collaboration diagram for ConfigFactory:

Public Member Functions

 getConfigNames ()
 
 makeConfig ($name)
 Create a given Config using the registered callback for $name. More...
 
 register ($name, $callback)
 Register a new config factory function. More...
 
 salvage (SalvageableService $other)
 Re-uses existing Cache objects from $other. More...
 

Static Public Member Functions

static getDefaultInstance ()
 

Protected Attributes

array $configs = []
 Config objects that have already been created name => Config object. More...
 
array $factoryFunctions = []
 Map of config name => callback. More...
 

Detailed Description

Factory class to create Config objects.

Since
1.23

Definition at line 31 of file ConfigFactory.php.

Member Function Documentation

ConfigFactory::getConfigNames ( )
Returns
string[]

Definition at line 93 of file ConfigFactory.php.

Referenced by MediaWikiTestCase\makeTestConfigFactoryInstantiator().

static ConfigFactory::getDefaultInstance ( )
static
Deprecated:
since 1.27, use MediaWikiServices::getConfigFactory() instead.
Returns
ConfigFactory

Definition at line 51 of file ConfigFactory.php.

Referenced by QuickTemplate\__construct(), PageArchive\__construct(), WikiImporter\__construct(), MediaWiki\Auth\Throttler\__construct(), AjaxResponse\__construct(), EmptyResourceLoader\__construct(), MediaWiki\Session\SessionManager\__construct(), ResourceLoader\__construct(), ImportLinkCacheIntegrationTest\doImport(), CleanupRemovedModules\execute(), ImportTextFiles\execute(), RequestContext\getConfig(), ResourceLoaderModule\getConfig(), Maintenance\getConfig(), MediaWiki\Auth\UserDataAuthenticationRequest\getFieldInfo(), SpecialUpload\getInitialPageText(), SpecialEmailUser\getPermissionsError(), MediaWiki\Auth\LegacyHookPreAuthenticationProviderTest\getProvider(), MediaWiki\Auth\LocalPasswordPrimaryAuthenticationProviderTest\getProvider(), MediaWiki\Auth\TemporaryPasswordPrimaryAuthenticationProviderTest\getProvider(), TemplateParser\getTemplate(), ResourceLoaderContext\newDummyContext(), MediaWiki\Auth\TemporaryPasswordAuthenticationRequest\newRandom(), CheckStorage\restoreText(), MediaWiki\Auth\AuthManager\singleton(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testCheckPasswordValidity(), MaintenanceTest\testGetConfig(), ConfigFactoryTest\testGetDefaultInstance(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetNewPasswordExpiry(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPassword(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testGetPasswordFactory(), ImportTest\testHandlePageContainsRedirect(), MediaWiki\Auth\AbstractPasswordPrimaryAuthenticationProviderTest\testSetPasswordResetFlag(), ImportTest\testSiteInfoContainsNamespaces(), and ImportTest\testUnknownXMLTags().

ConfigFactory::makeConfig (   $name)

Create a given Config using the registered callback for $name.

If an object was already created, the same Config object is returned.

Parameters
string$nameName of the extension/component you want a Config object for 'main' is used for core
Exceptions
ConfigExceptionIf a factory function isn't registered for $name
UnexpectedValueExceptionIf the factory function returns a non-Config object
Returns
Config

Definition at line 124 of file ConfigFactory.php.

References $name.

Referenced by MediaWikiTestCase\makeTestConfigFactoryInstantiator().

ConfigFactory::register (   $name,
  $callback 
)

Register a new config factory function.

Will override if it's already registered. Use "*" for $name to provide a fallback config for all unknown names.

Parameters
string$name
callable | Config$callbackA factory callabck that takes this ConfigFactory as an argument and returns a Config instance, or an existing Config instance.
Exceptions
InvalidArgumentExceptionIf an invalid callback is provided

Definition at line 106 of file ConfigFactory.php.

References $name.

ConfigFactory::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. Cache config is not copied, and only instances of caches defined on this instance with the same config are copied.

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

Implements MediaWiki\Services\SalvageableService.

Definition at line 66 of file ConfigFactory.php.

References $name, as, and class.

Member Data Documentation

array ConfigFactory::$configs = []
protected

Config objects that have already been created name => Config object.

Definition at line 44 of file ConfigFactory.php.

array ConfigFactory::$factoryFunctions = []
protected

Map of config name => callback.

Definition at line 37 of file ConfigFactory.php.


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