Skip to content
Snippets Groups Projects
Commit 367e1a88 authored by catch's avatar catch
Browse files

Issue #2250491 by damiankloip: Remove duplicate methods from Settings class.

parent e9696428
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -28,6 +28,17 @@ final class Settings {
*/
private static $instance;
/**
* Constructor.
*
* @param array $settings
* Array with the settings.
*/
public function __construct(array $settings) {
$this->storage = $settings;
self::$instance = $this;
}
/**
* Returns the settings instance.
*
......@@ -56,7 +67,7 @@ public static function getInstance() {
* The value of the setting, the provided default if not set.
*/
public static function get($name, $default = NULL) {
return self::$instance->getSetting($name, $default);
return isset(self::$instance->storage[$name]) ? self::$instance->storage[$name] : $default;
}
/**
......@@ -66,47 +77,7 @@ public static function get($name, $default = NULL) {
* All the settings.
*/
public static function getAll() {
return self::$instance->getAllSettings();
}
/**
* Constructor.
*
* @param array $settings
* Array with the settings.
*/
function __construct(array $settings) {
$this->storage = $settings;
self::$instance = $this;
}
/**
* 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.
*
* @param string $name
* The name of the setting to return.
* @param mixed $default
* (optional) The default value to use if this setting is not set.
*
* @return mixed
* The value of the setting, the provided default if not set.
*/
public function getSetting($name, $default = NULL) {
return isset($this->storage[$name]) ? $this->storage[$name] : $default;
}
/**
* Returns all the settings. This is only used for testing purposes.
*
* @return array
* All the settings.
*/
public function getAllSettings() {
return $this->storage;
return self::$instance->storage;
}
}
......@@ -39,7 +39,7 @@ public function __construct(Settings $settings) {
* {@inheritdoc}
*/
protected function getLanguage($langcode) {
return $this->settings->getSetting('locale_custom_strings_' . $langcode, array());
return $this->settings->get('locale_custom_strings_' . $langcode, array());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment