MediaWiki master
|
Settings loaded from a local file path. More...
Inherits Stringable, MediaWiki\Settings\Cache\CacheableSource, and MediaWiki\Settings\Source\SettingsIncludeLocator.
Public Member Functions | |
__construct (string $path, SettingsFormat $format=null) | |
Constructs a new FileSource for the given path and possibly a custom format to decode the contents. | |
__toString () | |
Returns this file source as a string. | |
allowsStaleLoad () | |
Disallow stale results from file sources in the case of load failure as failing to read from disk would be quite catastrophic and worthy of propagation. | |
getExpiryTtl () | |
The cache expiry TTL (in seconds) for this file source. | |
getExpiryWeight () | |
Coefficient used in determining early expiration of cached settings to avoid stampedes. | |
getHashKey () | |
Returns a hash key computed from the file's inode, size, and last modified timestamp. | |
load () | |
Loads contents from the file and decodes them using the first format to claim support for the file's extension. | |
locateInclude (string $location) | |
This method defines how a relative reference to the location of another settings source is interpreted. | |
MediaWiki\Settings\Source\FileSource::__construct | ( | string | $path, |
SettingsFormat | $format = null ) |
Constructs a new FileSource for the given path and possibly a custom format to decode the contents.
If no format is given, the built-in formats will be tried and the first one that supports the file extension will be used.
Built-in formats:
<?php $source = new FileSource( 'my/settings.json' ); $source->load();
While a specialized caller may want to pass a specialized format
<?php $source = new FileSource( 'my/settings.toml', new TomlFormat() ); $source->load();
string | $path | |
SettingsFormat | null | $format |
Definition at line 88 of file FileSource.php.
References $path.
MediaWiki\Settings\Source\FileSource::__toString | ( | ) |
MediaWiki\Settings\Source\FileSource::allowsStaleLoad | ( | ) |
Disallow stale results from file sources in the case of load failure as failing to read from disk would be quite catastrophic and worthy of propagation.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 100 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getExpiryTtl | ( | ) |
The cache expiry TTL (in seconds) for this file source.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 139 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getExpiryWeight | ( | ) |
Coefficient used in determining early expiration of cached settings to avoid stampedes.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 149 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::getHashKey | ( | ) |
Returns a hash key computed from the file's inode, size, and last modified timestamp.
Implements MediaWiki\Settings\Cache\CacheableSource.
Definition at line 159 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::load | ( | ) |
Loads contents from the file and decodes them using the first format to claim support for the file's extension.
SettingsBuilderException |
Implements MediaWiki\Settings\Source\SettingsSource.
Definition at line 111 of file FileSource.php.
MediaWiki\Settings\Source\FileSource::locateInclude | ( | string | $location | ) |
This method defines how a relative reference to the location of another settings source is interpreted.
It tries to make $location absolute by interpreting it as relative to the location of the SettingsSource it originates from.
Implementation are "best effort". If a location cannot be made absolute, it may be returned as-is. Implementations are also free to throw a SettingsBuilderException to indicate that the given include location is not supported in this context.
string | $location |
SettingsBuilderException | if the given location cannot be used as an include by the current source. |
Implements MediaWiki\Settings\Source\SettingsIncludeLocator.
Definition at line 226 of file FileSource.php.