function Settings::get

Same name in other branches
  1. 9 core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  2. 8.9.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\Settings::get()
  3. 11.x core/lib/Drupal/Core/Site/Settings.php \Drupal\Core\Site\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.

90 calls to Settings::get()
AssetsStream::basePath in core/lib/Drupal/Core/StreamWrapper/AssetsStream.php
Returns the base path for public://.
AssetsStream::baseUrl in core/lib/Drupal/Core/StreamWrapper/AssetsStream.php
Finds and returns the base URL for public://.
authorize_access_allowed in core/authorize.php
Determines if the current user is allowed to run authorize.php.
BootstrapConfigStorageFactory::get in core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
Returns a configuration storage implementation.
ClientFactory::fromOptions in core/lib/Drupal/Core/Http/ClientFactory.php
Constructs a new client object from some configuration.

... See full list

File

core/lib/Drupal/Core/Site/Settings.php, line 108

Class

Settings
Read only settings that are initialized with the class.

Namespace

Drupal\Core\Site

Code

public static function get($name, $default = NULL) {
    // If the caller is asking for the value of a deprecated setting, trigger a
    // deprecation message about it.
    if (isset(self::$deprecatedSettings[$name])) {
        // phpcs:ignore Drupal.Semantics.FunctionTriggerError
        @trigger_error(self::$deprecatedSettings[$name]['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.