function Settings::get
Same name in this branch
- main core/themes/admin/src/Settings.php \Drupal\admin\Settings::get()
- main core/themes/default_admin/src/Settings.php \Drupal\default_admin\Settings::get()
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
- 10 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
- 9 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
- 8.9.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
- 11.x core/themes/admin/src/Settings.php \Drupal\admin\Settings::get()
- 11.x core/themes/default_admin/src/Settings.php \Drupal\default_admin\Settings::get()
Returns a setting.
Settings can be set in settings.php in the $settings array and requested by this function. Settings should be used over configuration for read-only, possibly low bootstrap configuration that is environment specific.
Parameters
string $name: The name of the setting to return.
mixed $default: (optional) The default value to use if this setting is not set.
Return value
mixed The value of the setting, the provided default if not set.
111 calls to Settings::get()
- AssetsStream::basePath in core/
lib/ Drupal/ Core/ StreamWrapper/ AssetsStream.php - AssetsStream::baseUrl in core/
lib/ Drupal/ Core/ StreamWrapper/ AssetsStream.php - BootstrapConfigStorageFactory::get in core/
lib/ Drupal/ Core/ Config/ BootstrapConfigStorageFactory.php - Returns a configuration storage implementation.
- CacheTagPreloadSubscriber::onRequest in core/
lib/ Drupal/ Core/ Cache/ EventSubscriber/ CacheTagPreloadSubscriber.php - Preloads frequently used cache tags.
- ClientFactory::fromOptions in core/
lib/ Drupal/ Core/ Http/ ClientFactory.php - Constructs a new client object from some configuration.
File
-
core/
lib/ Drupal/ Core/ Site/ Settings.php, line 100
Class
- Settings
- Read only settings that are initialized with the class.
Namespace
Drupal\Core\SiteCode
public static function get($name, $default = NULL) {
if (isset(self::$deprecatedSettings[$name])) {
$deprecation = self::$deprecatedSettings[$name];
// Only trigger a deprecation warning if the setting has a replacement
// (calling code must be updated to use the new key) or if the setting is
// actually configured (the user must remove it from settings.php).
// Settings with no replacement that are not configured do not trigger a
// warning, to avoid spurious deprecations when the feature is simply not
// in use.
if (!empty($deprecation['replacement']) || array_key_exists($name, self::$instance->storage)) {
@trigger_error($deprecation['message'], E_USER_DEPRECATED);
}
}
return self::$instance->storage[$name] ?? $default;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.