diff --git a/core/authorize.php b/core/authorize.php index 8715fb04be5737b572e4d53f211744825f904ee3..2ddd7d6262a12bed28a39c4696b6548c1b48acab 100644 --- a/core/authorize.php +++ b/core/authorize.php @@ -20,7 +20,7 @@ * @link authorize Authorized operation helper functions @endlink */ -use Symfony\Component\HttpFoundation\Request; +use Drupal\Component\Utility\Settings; // Change the directory to the Drupal root. chdir('..'); @@ -46,9 +46,9 @@ * TRUE if the current user can run authorize.php, and FALSE if not. */ function authorize_access_allowed() { - require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); + require_once DRUPAL_ROOT . '/' . Settings::get('session_inc', 'core/includes/session.inc'); drupal_session_initialize(); - return settings()->get('allow_authorize_operations', TRUE) && user_access('administer software updates'); + return Settings::get('allow_authorize_operations', TRUE) && user_access('administer software updates'); } // *** Real work of the script begins here. *** diff --git a/core/core.services.yml b/core/core.services.yml index 32881daf4913051338443500765c9d0dc26820d2..b238304bf9ff004e1546e351feb31645ecbaa9e9 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -144,7 +144,7 @@ services: settings: class: Drupal\Component\Utility\Settings factory_class: Drupal\Component\Utility\Settings - factory_method: getSingleton + factory_method: getInstance state: class: Drupal\Core\KeyValueStore\State arguments: ['@keyvalue'] diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index e38cfda53c1a72ab5b59db71fa1427a1935e38b7..2351ce3eac9e5d7600d5541b263279c3f330d6de 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -621,20 +621,6 @@ function drupal_get_filename($type, $name, $filename = 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. - * - * @return \Drupal\Component\Utility\Settings - * The settings object. - */ -function settings() { - return Settings::getSingleton(); -} - /** * Gets the page cache cid for this request. * @@ -946,7 +932,7 @@ function drupal_serve_page_from_cache(stdClass $cache, Response $response, Reque // fields that fully determines whether a cache is permitted to use the // response to reply to a subsequent request for a given URL without // revalidation. - if (!isset($boot_headers['vary']) && !settings()->get('omit_vary_cookie')) { + if (!isset($boot_headers['vary']) && !Settings::get('omit_vary_cookie')) { $response->setVary('Cookie', FALSE); } @@ -1514,7 +1500,7 @@ function drupal_get_user_timezone() { * A salt based on information in settings.php, not in the database. */ function drupal_get_hash_salt() { - $hash_salt = settings()->get('hash_salt'); + $hash_salt = Settings::get('hash_salt'); // This should never happen, as it breaks user logins and many other services. // Therefore, explicitly notify the user (developer) by throwing an exception. if (empty($hash_salt)) { @@ -1642,7 +1628,7 @@ function _drupal_bootstrap_page_cache() { require_once __DIR__ . '/database.inc'; // Check for a cache mode force from settings.php. - if (settings()->get('page_cache_without_database')) { + if (Settings::get('page_cache_without_database')) { $cache_enabled = TRUE; } else { @@ -2113,7 +2099,7 @@ function drupal_classloader($class_loader = NULL) { // findFile() method, but none of the others. The actual registry is still // in ClassLoader. if (!isset($class_loader)) { - $class_loader = settings()->get('class_loader', 'default'); + $class_loader = Settings::get('class_loader', 'default'); } if ($class_loader === 'apc') { require_once __DIR__ . '/../vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php'; diff --git a/core/includes/common.inc b/core/includes/common.inc index 7bb6d06c7a24da859d767f39ab44fd4e52a86a90..e6cc3235bf5e4f5956513eef607b4b269ec6421c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -207,7 +207,7 @@ function drupal_get_profile() { } } else { - $profile = settings()->get('install_profile') ?: 'standard'; + $profile = Settings::get('install_profile') ?: 'standard'; } return $profile; @@ -496,7 +496,7 @@ function _external_url_is_local($url) { * TRUE if a proxy should be used for this host. */ function _drupal_http_use_proxy($host) { - $proxy_exceptions = settings()->get('proxy_exceptions', array('localhost', '127.0.0.1')); + $proxy_exceptions = Settings::get('proxy_exceptions', array('localhost', '127.0.0.1')); return !in_array(strtolower($host), $proxy_exceptions, TRUE); } @@ -3077,11 +3077,11 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) { * Loads code for subsystems and modules, and registers stream wrappers. */ function _drupal_bootstrap_code() { - require_once __DIR__ . '/../../' . settings()->get('path_inc', 'core/includes/path.inc'); + require_once __DIR__ . '/../../' . Settings::get('path_inc', 'core/includes/path.inc'); require_once __DIR__ . '/module.inc'; require_once __DIR__ . '/theme.inc'; require_once __DIR__ . '/pager.inc'; - require_once __DIR__ . '/../../' . settings()->get('menu_inc', 'core/includes/menu.inc'); + require_once __DIR__ . '/../../' . Settings::get('menu_inc', 'core/includes/menu.inc'); require_once __DIR__ . '/tablesort.inc'; require_once __DIR__ . '/file.inc'; require_once __DIR__ . '/unicode.inc'; diff --git a/core/includes/database.inc b/core/includes/database.inc index 0064ee46fa155a0f5eca2d7af3f4ba322253555e..0197377c5df6990d4071fa219f10435c101a1c8c 100644 --- a/core/includes/database.inc +++ b/core/includes/database.inc @@ -1,5 +1,6 @@ get('maximum_replication_lag', 300); + $duration = Settings::get('maximum_replication_lag', 300); // Set session variable with amount of time to delay before using slave. $_SESSION['ignore_slave_server'] = REQUEST_TIME + $duration; } diff --git a/core/includes/file.inc b/core/includes/file.inc index f08070ec47b68917e5064c4fe9033b0eb606b239..baaf6547ef85c906e42b0646fc765de0a0c56b2a 100644 --- a/core/includes/file.inc +++ b/core/includes/file.inc @@ -7,6 +7,7 @@ use Drupal\Core\StreamWrapper\LocalStream; use Drupal\Component\PhpStorage\FileStorage; +use Drupal\Component\Utility\Settings; use Drupal\Component\Utility\String; use Drupal\Core\StreamWrapper\PublicStream; @@ -1336,10 +1337,10 @@ function file_get_mimetype($uri, $mapping = NULL) { function drupal_chmod($uri, $mode = NULL) { if (!isset($mode)) { if (is_dir($uri)) { - $mode = settings()->get('file_chmod_directory', FILE_CHMOD_DIRECTORY); + $mode = Settings::get('file_chmod_directory', FILE_CHMOD_DIRECTORY); } else { - $mode = settings()->get('file_chmod_file', FILE_CHMOD_FILE); + $mode = Settings::get('file_chmod_file', FILE_CHMOD_FILE); } } @@ -1513,7 +1514,7 @@ function drupal_basename($uri, $suffix = NULL) { */ function drupal_mkdir($uri, $mode = NULL, $recursive = FALSE, $context = NULL) { if (!isset($mode)) { - $mode = settings()->get('file_chmod_directory', FILE_CHMOD_DIRECTORY); + $mode = Settings::get('file_chmod_directory', FILE_CHMOD_DIRECTORY); } // If the URI has a scheme, don't override the umask - schemes can handle this diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index e534003b35ff6283f5000c764763b76736c38866..5244ced8387c65e18753e91f172558d5f4ff0acc 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -294,7 +294,7 @@ function install_begin_request(&$install_state) { require_once __DIR__ . '/file.inc'; require_once __DIR__ . '/install.inc'; require_once __DIR__ . '/schema.inc'; - require_once __DIR__ . '/../../' . settings()->get('path_inc', 'core/includes/path.inc'); + require_once __DIR__ . '/../../' . Settings::get('path_inc', 'core/includes/path.inc'); require_once __DIR__ . '/database.inc'; require_once __DIR__ . '/form.inc'; require_once __DIR__ . '/batch.inc'; @@ -1777,7 +1777,7 @@ function install_load_profile(&$install_state) { */ function install_bootstrap_full() { drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); - require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); + require_once DRUPAL_ROOT . '/' . Settings::get('session_inc', 'core/includes/session.inc'); drupal_session_initialize(); } diff --git a/core/includes/install.inc b/core/includes/install.inc index 5c757741b06833f554563954c2967977ee09e984..e8a21e43b63f14b1e3be7fea57a1a760693570d4 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -317,7 +317,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) { // In case any $settings variables were written, import them into the // Settings singleton. if (!empty($settings_settings)) { - $old_settings = settings()->getAll(); + $old_settings = Settings::getAll(); new Settings($settings_settings + $old_settings); } } diff --git a/core/includes/mail.inc b/core/includes/mail.inc index 0a0896d7065bc3569fab1dd43f9dd0012e025f2c..8c8b071c8419653486f2fbbe522000f13fb529c5 100644 --- a/core/includes/mail.inc +++ b/core/includes/mail.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Html; +use Drupal\Component\Utility\Settings; use Drupal\Component\Utility\Xss; /** @@ -426,7 +427,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) { if (isset($casing)) { $chunk = $casing($chunk); } - $line_endings = settings()->get('mail_line_endings', PHP_EOL); + $line_endings = Settings::get('mail_line_endings', PHP_EOL); // Format it and apply the current indentation. $output .= drupal_wrap_mail($chunk, implode('', $indent)) . $line_endings; // Remove non-quotation markers from indentation. diff --git a/core/includes/session.inc b/core/includes/session.inc index 839ead824f688e547a5d71e845489135dad26ace..8e95036377590df6af4d99969ddea308e52fcbbf 100644 --- a/core/includes/session.inc +++ b/core/includes/session.inc @@ -17,6 +17,7 @@ */ use Drupal\Component\Utility\Crypt; +use Drupal\Component\Utility\Settings; use Drupal\Core\Session\UserSession; use Drupal\Core\Utility\Error; @@ -175,7 +176,7 @@ function _drupal_session_write($sid, $value) { // For performance reasons, do not update the sessions table, unless // $_SESSION has changed or more than 180 has passed since the last update. - if ($is_changed || !$user->getLastAccessedTime() || REQUEST_TIME - $user->getLastAccessedTime() > settings()->get('session_write_interval', 180)) { + if ($is_changed || !$user->getLastAccessedTime() || REQUEST_TIME - $user->getLastAccessedTime() > Settings::get('session_write_interval', 180)) { // Either ssid or sid or both will be added from $key below. $fields = array( 'uid' => $user->id(), @@ -196,14 +197,14 @@ function _drupal_session_write($sid, $value) { // secure and insecure session cookies. If enabled and both cookies are // presented then use both keys. The session ID from the cookie is // hashed before being stored in the database as a security measure. - if (settings()->get('mixed_mode_sessions', FALSE)) { + if (Settings::get('mixed_mode_sessions', FALSE)) { $insecure_session_name = substr(session_name(), 1); if ($cookies->has($insecure_session_name)) { $key['sid'] = Crypt::hashBase64($cookies->get($insecure_session_name)); } } } - elseif (settings()->get('mixed_mode_sessions', FALSE)) { + elseif (Settings::get('mixed_mode_sessions', FALSE)) { unset($key['ssid']); } @@ -214,7 +215,7 @@ function _drupal_session_write($sid, $value) { } // Likewise, do not update access time more than once per 180 seconds. - if ($user->isAuthenticated() && REQUEST_TIME - $user->getLastAccessedTime() > settings()->get('session_write_interval', 180)) { + if ($user->isAuthenticated() && REQUEST_TIME - $user->getLastAccessedTime() > Settings::get('session_write_interval', 180)) { db_update('users') ->fields(array( 'access' => REQUEST_TIME @@ -247,7 +248,7 @@ function drupal_session_initialize() { $is_https = \Drupal::request()->isSecure(); $cookies = \Drupal::request()->cookies; - if (($cookies->has(session_name()) && ($session_name = $cookies->get(session_name()))) || ($is_https && settings()->get('mixed_mode_sessions', FALSE) && ($cookies->has(substr(session_name(), 1))) && ($session_name = $cookies->get(substr(session_name(), 1))))) { + if (($cookies->has(session_name()) && ($session_name = $cookies->get(session_name()))) || ($is_https && Settings::get('mixed_mode_sessions', FALSE) && ($cookies->has(substr(session_name(), 1))) && ($session_name = $cookies->get(substr(session_name(), 1))))) { // If a session cookie exists, initialize the session. Otherwise the // session is only started on demand in drupal_session_commit(), making // anonymous users not use a session cookie unless something is stored in @@ -268,7 +269,7 @@ function drupal_session_initialize() { // anonymous users than are generated in drupal_session_regenerate() when // a user becomes authenticated. session_id(Crypt::randomBytesBase64()); - if ($is_https && settings()->get('mixed_mode_sessions', FALSE)) { + if ($is_https && Settings::get('mixed_mode_sessions', FALSE)) { $insecure_session_name = substr(session_name(), 1); $session_id = Crypt::randomBytesBase64(); $cookies->set($insecure_session_name, $session_id); @@ -323,7 +324,7 @@ function drupal_session_commit() { // started. if (!drupal_session_started()) { drupal_session_start(); - if (\Drupal::request()->isSecure() && settings()->get('mixed_mode_sessions', FALSE)) { + if (\Drupal::request()->isSecure() && Settings::get('mixed_mode_sessions', FALSE)) { $insecure_session_name = substr(session_name(), 1); $params = session_get_cookie_params(); $expire = $params['lifetime'] ? REQUEST_TIME + $params['lifetime'] : 0; @@ -363,7 +364,7 @@ function drupal_session_regenerate() { $is_https = \Drupal::request()->isSecure(); $cookies = \Drupal::request()->cookies; - if ($is_https && settings()->get('mixed_mode_sessions', FALSE)) { + if ($is_https && Settings::get('mixed_mode_sessions', FALSE)) { $insecure_session_name = substr(session_name(), 1); if (!isset($GLOBALS['lazy_session']) && $cookies->has($insecure_session_name)) { $old_insecure_session_id = $cookies->get($insecure_session_name); @@ -392,7 +393,7 @@ function drupal_session_regenerate() { $fields['ssid'] = Crypt::hashBase64(session_id()); // If the "secure pages" setting is enabled, use the newly-created // insecure session identifier as the regenerated sid. - if (settings()->get('mixed_mode_sessions', FALSE)) { + if (Settings::get('mixed_mode_sessions', FALSE)) { $fields['sid'] = Crypt::hashBase64($session_id); } } @@ -453,7 +454,7 @@ function _drupal_session_destroy($sid) { if ($is_https) { _drupal_session_delete_cookie(substr(session_name(), 1), FALSE); } - elseif (settings()->get('mixed_mode_sessions', FALSE)) { + elseif (Settings::get('mixed_mode_sessions', FALSE)) { _drupal_session_delete_cookie('S' . session_name(), TRUE); } } diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index d49338d51cfdff2bd70499e8771f0f5a44325ed5..d3023b9a65f51f20c194a54819643cc152896ad8 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -6,6 +6,7 @@ */ use Drupal\Component\Utility\Unicode; +use Drupal\Component\Utility\Settings; /** * Sets up the theming system for maintenance page. @@ -24,7 +25,7 @@ function _drupal_maintenance_theme() { return; } - require_once DRUPAL_ROOT . '/' . settings()->get('path_inc', 'core/includes/path.inc'); + require_once DRUPAL_ROOT . '/' . Settings::get('path_inc', 'core/includes/path.inc'); require_once __DIR__ . '/theme.inc'; require_once __DIR__ . '/common.inc'; require_once __DIR__ . '/unicode.inc'; @@ -38,7 +39,7 @@ function _drupal_maintenance_theme() { $custom_theme = $GLOBALS['install_state']['theme']; } else { - $custom_theme = settings()->get('maintenance_theme', 'seven'); + $custom_theme = Settings::get('maintenance_theme', 'seven'); } } else { @@ -52,7 +53,7 @@ function _drupal_maintenance_theme() { // Use the maintenance theme if specified, otherwise attempt to use the // default site theme. try { - $custom_theme = settings()->get('maintenance_theme', ''); + $custom_theme = Settings::get('maintenance_theme', ''); if (!$custom_theme) { $config = \Drupal::config('system.theme'); $custom_theme = $config->get('default'); diff --git a/core/lib/Drupal/Component/Diff/DiffEngine.php b/core/lib/Drupal/Component/Diff/DiffEngine.php index 01943792631b36d1bed6d4c8a09cffb92ce58f13..21d9ad486e1915a86023192c7c5ea36929bc2ea5 100644 --- a/core/lib/Drupal/Component/Diff/DiffEngine.php +++ b/core/lib/Drupal/Component/Diff/DiffEngine.php @@ -1100,8 +1100,8 @@ class DrupalDiffFormatter extends DiffFormatter { ); function DrupalDiffFormatter() { - $this->leading_context_lines = Settings::getSingleton()->get('diff_context_lines_leading', 2); - $this->trailing_context_lines = Settings::getSingleton()->get('diff_context_lines_trailing', 2); + $this->leading_context_lines = Settings::get('diff_context_lines_leading', 2); + $this->trailing_context_lines = Settings::get('diff_context_lines_trailing', 2); } function _start_diff() { diff --git a/core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php b/core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php index 0939799286e3629d4297ecfcf54a643705b9d0a5..3eb1698ce27c42052e74c9eb7cb35df73b5b97f1 100644 --- a/core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php +++ b/core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php @@ -34,7 +34,7 @@ class PhpStorageFactory { * An instantiated storage controller for the specified name. */ static function get($name) { - $overrides = Settings::getSingleton()->get('php_storage'); + $overrides = Settings::get('php_storage'); if (isset($overrides[$name])) { $configuration = $overrides[$name]; } diff --git a/core/lib/Drupal/Component/Utility/Settings.php b/core/lib/Drupal/Component/Utility/Settings.php index eb59e661da7fb7f8c9c52a5c9280d09620a82e77..f6f5e915748297e25d5a9a9a9e9c4210dda82128 100644 --- a/core/lib/Drupal/Component/Utility/Settings.php +++ b/core/lib/Drupal/Component/Utility/Settings.php @@ -34,10 +34,39 @@ final class Settings { * * @return \Drupal\Component\Utility\Settings */ - public static function getSingleton() { + public static function getInstance() { return self::$instance; } + /** + * 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 static function get($name, $default = NULL) { + return self::$instance->getSetting($name, $default); + } + + /** + * Returns all the settings. This is only used for testing purposes. + * + * @return array + * All the settings. + */ + public static function getAll() { + return self::$instance->getAllSettings(); + } + /** * Constructor. * @@ -64,7 +93,7 @@ function __construct(array $settings) { * @return mixed * The value of the setting, the provided default if not set. */ - public function get($name, $default = NULL) { + public function getSetting($name, $default = NULL) { return isset($this->storage[$name]) ? $this->storage[$name] : $default; } @@ -74,7 +103,7 @@ public function get($name, $default = NULL) { * @return array * All the settings. */ - public function getAll() { + public function getAllSettings() { return $this->storage; } diff --git a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php index ae108dcb42fb4b4239b14ef018afd32b2054b593..1a7b256fcc1081e30dbefe5e4903da7c084fd757 100644 --- a/core/lib/Drupal/Core/Authentication/Provider/Cookie.php +++ b/core/lib/Drupal/Core/Authentication/Provider/Cookie.php @@ -8,10 +8,8 @@ namespace Drupal\Core\Authentication\Provider; use Drupal\Core\Authentication\AuthenticationProviderInterface; -use Symfony\Component\HttpFoundation\RedirectResponse; -use Symfony\Component\HttpFoundation\Response; +use Drupal\Component\Utility\Settings; use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; /** @@ -32,7 +30,7 @@ public function applies(Request $request) { public function authenticate(Request $request) { // Global $user is deprecated, but the session system is still based on it. global $user; - require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); + require_once DRUPAL_ROOT . '/' . Settings::get('session_inc', 'core/includes/session.inc'); drupal_session_initialize(); if (drupal_session_started()) { return $user; diff --git a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php index 054e6907da742d4535afe050e928ed995b9e6d8a..e075261e04d3ecfd46e3ffbdd6380a16eb7d3796 100644 --- a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php +++ b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php @@ -6,6 +6,7 @@ */ namespace Drupal\Core\Config; + use Drupal\Component\Utility\Settings; /** @@ -20,8 +21,7 @@ class BootstrapConfigStorageFactory { * A configuration storage implementation. */ public static function get() { - $settings = Settings::getSingleton(); - $drupal_bootstrap_config_storage = $settings->get('drupal_bootstrap_config_storage'); + $drupal_bootstrap_config_storage = Settings::get('drupal_bootstrap_config_storage'); if ($drupal_bootstrap_config_storage && is_callable($drupal_bootstrap_config_storage)) { return call_user_func($drupal_bootstrap_config_storage); } diff --git a/core/lib/Drupal/Core/CoreServiceProvider.php b/core/lib/Drupal/Core/CoreServiceProvider.php index 01ab8774a14d94541a26e2af3a79828a63b7bd56..184c76743bf0b3319d9d2034f5cae91669a522bc 100644 --- a/core/lib/Drupal/Core/CoreServiceProvider.php +++ b/core/lib/Drupal/Core/CoreServiceProvider.php @@ -8,6 +8,7 @@ namespace Drupal\Core; use Drupal\Core\Cache\CacheContextsPass; +use Drupal\Component\Utility\Settings; use Drupal\Core\Cache\ListCacheBinsPass; use Drupal\Core\Config\ConfigFactoryOverridePass; use Drupal\Core\DependencyInjection\ServiceProviderInterface; @@ -111,12 +112,12 @@ public static function registerTwig(ContainerBuilder $container) { // @todo ensure garbage collection of expired files. // When in the installer, twig_cache must be FALSE until we know the // files folder is writable. - 'cache' => drupal_installation_attempted() ? FALSE : settings()->get('twig_cache', TRUE), + 'cache' => drupal_installation_attempted() ? FALSE : Settings::get('twig_cache', TRUE), // @todo Remove in followup issue // @see http://drupal.org/node/1712444. 'autoescape' => FALSE, - 'debug' => settings()->get('twig_debug', FALSE), - 'auto_reload' => settings()->get('twig_auto_reload', NULL), + 'debug' => Settings::get('twig_debug', FALSE), + 'auto_reload' => Settings::get('twig_auto_reload', NULL), )) ->addArgument(new Reference('module_handler')) ->addArgument(new Reference('theme_handler')) diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php index d69af77eb443f09963d0da14ad4d35aa1d586859..4873bac9de80c188dc3e74435e27336bc54d01d9 100644 --- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php +++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php @@ -131,7 +131,7 @@ public function scan($type, $include_tests = NULL) { // Therefore, add the site directory of the parent site to the search paths, // so that contained extensions are still discovered. // @see \Drupal\simpletest\WebTestBase::setUp() - if ($parent_site = Settings::getSingleton()->get('test_parent_site')) { + if ($parent_site = Settings::get('test_parent_site')) { $searchdirs[static::ORIGIN_PARENT_SITE] = $parent_site; } diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 12316897f85ff3ed106a171384fb17f3b52d28d8..424b4646d36903630bca5cf073d193babd891930 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\NestedArray; +use Drupal\Component\Utility\Settings; use Drupal\Component\Utility\Unicode; use Drupal\Component\Utility\UrlHelper; use Drupal\Core\Access\CsrfTokenGenerator; @@ -1287,7 +1288,7 @@ public function doBuildForm($form_id, &$element, &$form_state) { // Special handling if we're on the top level form element. if (isset($element['#type']) && $element['#type'] == 'form') { - if (!empty($element['#https']) && settings()->get('mixed_mode_sessions', FALSE) && + if (!empty($element['#https']) && Settings::get('mixed_mode_sessions', FALSE) && !UrlHelper::isExternal($element['#action'])) { global $base_root; diff --git a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php index e8086ee008d8b36bd8719454c27410f7b1606f21..874f246e936f0ab3f4d3c41d58a61896d122f57e 100644 --- a/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php +++ b/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php @@ -7,6 +7,7 @@ namespace Drupal\Core\Mail\Plugin\Mail; +use Drupal\Component\Utility\Settings; use Drupal\Core\Mail\MailInterface; /** @@ -66,7 +67,7 @@ public function mail(array $message) { foreach ($message['headers'] as $name => $value) { $mimeheaders[] = $name . ': ' . mime_header_encode($value); } - $line_endings = settings()->get('mail_line_endings', PHP_EOL); + $line_endings = Settings::get('mail_line_endings', PHP_EOL); // Prepare mail commands. $mail_subject = mime_header_encode($message['subject']); // Note: e-mail uses CRLF for line-endings. PHP's API requires LF diff --git a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php index 760a1f82e91f4a836d01e695808787d3c89b8fd8..8f798f579ae1f5efba158976ed7cfe7ffa9f5288 100644 --- a/core/lib/Drupal/Core/StreamWrapper/PublicStream.php +++ b/core/lib/Drupal/Core/StreamWrapper/PublicStream.php @@ -7,6 +7,8 @@ namespace Drupal\Core\StreamWrapper; +use Drupal\Component\Utility\Settings; + /** * Defines a Drupal public (public://) stream wrapper class. * @@ -37,7 +39,7 @@ public function getExternalUrl() { * The base path for public:// typically sites/default/files. */ public static function basePath() { - $base_path = settings()->get('file_public_path', conf_path() . '/files'); + $base_path = Settings::get('file_public_path', conf_path() . '/files'); return $base_path; } diff --git a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php index 667c3eb66ba0048c937f079f2ad1c24bb06cef6a..0b564fcffef9f1fdf08777ffbececd6832ee9ec3 100644 --- a/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php +++ b/core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php @@ -39,7 +39,7 @@ public function __construct(Settings $settings) { * {@inheritdoc} */ protected function getLanguage($langcode) { - return $this->settings->get('locale_custom_strings_' . $langcode, array()); + return $this->settings->getSetting('locale_custom_strings_' . $langcode, array()); } } diff --git a/core/lib/Drupal/Core/Template/TwigNodeTrans.php b/core/lib/Drupal/Core/Template/TwigNodeTrans.php index dddc273d9344054fcbb4cb828733a9a13f9098c5..2ff3b0898cc4d458e200bf1eea4f2a47b1492563 100644 --- a/core/lib/Drupal/Core/Template/TwigNodeTrans.php +++ b/core/lib/Drupal/Core/Template/TwigNodeTrans.php @@ -14,6 +14,7 @@ namespace Drupal\Core\Template; +use Drupal\Component\Utility\Settings; use Drupal\Component\Utility\Unicode; /** @@ -82,7 +83,7 @@ public function compile(\Twig_Compiler $compiler) { $compiler->raw(')'); // Append translation debug markup, if necessary. - if (settings()->get('twig_debug', FALSE)) { + if (Settings::get('twig_debug', FALSE)) { $compiler->raw(" . '\n"; $output['debug_prefix'] .= "\n"; // If there are theme suggestions, reverse the array so more specific diff --git a/core/update.php b/core/update.php index a2de6fcd547f6d7bbc3fd2be25a020a6ac2489fa..cd94972eafadf95c48186c57a02a9d32afa6d476 100644 --- a/core/update.php +++ b/core/update.php @@ -120,7 +120,7 @@ function update_results_page() { $output .= '

'; } - if (settings()->get('update_free_access')) { + if (Settings::get('update_free_access')) { $output .= "

Reminder: don't forget to set the \$settings['update_free_access'] value in your settings.php file back to FALSE.

"; } @@ -256,7 +256,7 @@ function update_access_allowed() { $user = \Drupal::currentUser(); // Allow the global variable in settings.php to override the access check. - if (settings()->get('update_free_access')) { + if (Settings::get('update_free_access')) { return TRUE; } // Calls to user_access() might fail during the Drupal 6 to 7 update process, @@ -335,7 +335,7 @@ function update_task_list($active = NULL) { // below. require_once __DIR__ . '/includes/module.inc'; -$settings = settings()->getAll(); +$settings = Settings::getAll(); new Settings($settings); $kernel = new DrupalKernel('update', drupal_classloader(), FALSE); $kernel->boot(); @@ -345,7 +345,7 @@ function update_task_list($active = NULL) { // Determine if the current user has access to run update.php. drupal_bootstrap(DRUPAL_BOOTSTRAP_PAGE_CACHE); -require_once DRUPAL_ROOT . '/' . settings()->get('session_inc', 'core/includes/session.inc'); +require_once DRUPAL_ROOT . '/' . Settings::get('session_inc', 'core/includes/session.inc'); drupal_session_initialize(); // Ensure that URLs generated for the home and admin pages don't have 'update.php'