MediaWiki master
MediaWiki\Config\ServiceOptions Class Reference

A class for passing options to services. More...

Public Member Functions

 __construct (array $keys,... $sources)
 
 assertRequiredOptions (array $expectedKeys)
 Assert that the list of options provided in this instance exactly match $expectedKeys, without regard for order.
 
 get ( $key)
 

Detailed Description

A class for passing options to services.

It can be constructed from a Config, and in practice most options will be taken from site configuration, but they don't have to be. The options passed are copied and will not reflect subsequent updates to site configuration (assuming they're not objects).

Services that take this type as a parameter to their constructor should specify a list of the keys they expect to receive in an array. The convention is to make it a public const called CONSTRUCTOR_OPTIONS. In the constructor, they should call assertRequiredOptions() to make sure that they weren't passed too few or too many options. This way it's clear what each class depends on, and that it's getting passed the correct set of options. (This means there are no optional options. This makes sense for services, since they shouldn't be constructed by outside code.)

Stability: newable
since 1.36
Since
1.34

Definition at line 26 of file ServiceOptions.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Config\ServiceOptions::__construct ( array  $keys,
  $sources 
)
Stability: stable
to call since 1.36
Parameters
string[]$keysWhich keys to extract from $sources
Config|ServiceOptions|array...$sources Each source is either a Config object or an array. If the same key is present in two sources, the first one takes precedence. Keys that are not in $keys are ignored.
Exceptions
InvalidArgumentExceptionif one of $keys is not found in any of $sources

Definition at line 39 of file ServiceOptions.php.

References $source.

Member Function Documentation

◆ assertRequiredOptions()

MediaWiki\Config\ServiceOptions::assertRequiredOptions ( array  $expectedKeys)

Assert that the list of options provided in this instance exactly match $expectedKeys, without regard for order.

Parameters
string[]$expectedKeys

Definition at line 70 of file ServiceOptions.php.

Referenced by MediaWiki\Rest\Router\__construct(), MediaWiki\Storage\EditResultCache\__construct(), MediaWiki\Parser\ParserCacheFactory\__construct(), MediaWiki\Page\DeletePage\__construct(), MediaWiki\ChangeTags\ChangeTagsStore\__construct(), MediaWiki\Storage\BlobStoreFactory\__construct(), MediaWiki\Storage\EditResultBuilder\__construct(), MediaWiki\Storage\RevertedTagUpdate\__construct(), MediaWiki\Storage\PageUpdaterFactory\__construct(), MediaWiki\Parser\Parsoid\Config\SiteConfig\__construct(), MediaWiki\User\PasswordReset\__construct(), MediaWiki\Parser\Parsoid\Config\DataAccess\__construct(), MediaWiki\Permissions\GrantsInfo\__construct(), MediaWiki\Permissions\GroupPermissionsLookup\__construct(), MediaWiki\Tidy\RemexDriver\__construct(), MediaWiki\Block\BlockUtilsFactory\__construct(), MediaWiki\Block\BlockUser\__construct(), MediaWiki\Block\BlockPermissionCheckerFactory\__construct(), MediaWiki\Block\BlockPermissionChecker\__construct(), MediaWiki\Preferences\SignatureValidatorFactory\__construct(), MediaWiki\User\BotPasswordStore\__construct(), MediaWiki\User\Options\UserOptionsManager\__construct(), MediaWiki\Languages\LanguageNameUtils\__construct(), MediaWiki\Title\NamespaceInfo\__construct(), MediaWiki\Block\UserBlockCommandFactory\__construct(), MediaWiki\Mail\EmailUserFactory\__construct(), MediaWiki\Mail\EmailUser\__construct(), MediaWiki\Page\RollbackPage\__construct(), MediaWiki\Page\PageStoreFactory\__construct(), WatchedItemStore\__construct(), MediaWiki\User\UserFactory\__construct(), MediaWiki\User\ActorStoreFactory\__construct(), MediaWiki\Page\PageStore\__construct(), MediaWiki\Deferred\LinksUpdate\PagePropsTable\__construct(), MediaWiki\User\Options\DefaultOptionsLookup\__construct(), MediaWiki\User\UserNameUtils\__construct(), MediaWiki\Search\TitleMatcher\__construct(), MediaWiki\Preferences\DefaultPreferencesFactory\__construct(), MediaWiki\SpecialPage\SpecialPageFactory\__construct(), MediaWiki\Interwiki\ClassicInterwikiLookup\__construct(), LocalisationCache\__construct(), MediaWiki\Cache\BacklinkCache\__construct(), MediaWiki\Block\DatabaseBlockStore\__construct(), MediaWiki\Block\DatabaseBlockStoreFactory\__construct(), MediaWiki\Http\HttpRequestFactory\__construct(), MediaWiki\Languages\LanguageFactory\__construct(), MediaWiki\Category\TrackingCategories\__construct(), MediaWiki\User\Registration\UserRegistrationLookup\__construct(), MediaWiki\Languages\LanguageConverterFactory\__construct(), MediaWiki\Collation\CollationFactory\__construct(), MediaWiki\User\CentralId\CentralIdLookupFactory\__construct(), MediaWiki\JobQueue\JobQueueGroupFactory\__construct(), MediaWiki\User\UserGroupManager\__construct(), MediaWiki\Rest\CorsUtils\__construct(), MediaWiki\Permissions\PermissionManager\__construct(), MediaWiki\EditPage\Constraint\EditConstraintFactory\__construct(), MediaWiki\Block\BlockManager\__construct(), MediaWiki\Preferences\SignatureValidator\__construct(), MediaWiki\Block\BlockUtils\__construct(), MediaWiki\User\Options\ConditionalDefaultsLookup\__construct(), MediaWiki\Permissions\RestrictionStore\__construct(), MediaWiki\Permissions\RateLimiter\__construct(), MediaWiki\User\TalkPageNotificationManager\__construct(), JobRunner\__construct(), MediaWiki\Parser\Parser\__construct(), ParserFactory\__construct(), MediaWiki\Linker\LinkRenderer\__construct(), MediaWiki\Storage\PageUpdater\__construct(), and MessageCache\__construct().

◆ get()


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