Settings
final class Settings (View source)
Read only settings that are initialized with the class.
Methods
Constructor.
Returns the settings instance.
Prevents settings from being serialized.
Returns a setting.
Returns all the settings. This is only used for testing purposes.
Bootstraps settings.php and the Settings singleton.
Gets a salt useful for hardening against SQL injection.
Generates a prefix for APCu user cache keys.
Details
__construct(array $settings)
Constructor.
static Settings
getInstance()
Returns the settings instance.
A singleton is used because this class is used before the container is available.
__sleep()
Prevents settings from being serialized.
static mixed
get(string $name, mixed $default = NULL)
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.
static array
getAll()
Returns all the settings. This is only used for testing purposes.
static
initialize(string $app_root, string $site_path, ClassLoader $class_loader)
Bootstraps settings.php and the Settings singleton.
static string
getHashSalt()
Gets a salt useful for hardening against SQL injection.
static string
getApcuPrefix(string $identifier, string $root, string $site_path = '')
Generates a prefix for APCu user cache keys.
A standardized prefix is useful to allow visual inspection of an APCu user cache. By default, this method will produce a unique prefix per site using the hash salt. If the setting 'apcu_ensure_unique_prefix' is set to FALSE then if the caller does not provide a $site_path only the Drupal root will be used. This allows tests to use the same prefix ensuring that the number of APCu items created during a full test run is kept to a minimum. Additionally, if a multi site implementation does not use site specific module directories setting apcu_ensure_unique_prefix would allow the sites to share APCu cache items.