diff --git a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php index 57bea76..ffc8f48 100644 --- a/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php +++ b/core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Config; use Drupal\Core\Database\Database; +use Drupal\Component\Utility\Settings; /** * Defines a factory for retrieving the config storage used pre-kernel. @@ -15,6 +16,21 @@ class BootstrapConfigStorageFactory { /** + * Returns a configuration storage implementation. + * + * @return \Drupal\Core\Config\StorageInterface + * A configuration storage implementation. + */ + public static function get() { + $bootstrap_config_storage = Settings::get('bootstrap_config_storage'); + if (!empty($bootstrap_config_storage) && is_callable($bootstrap_config_storage)) { + return call_user_func($bootstrap_config_storage); + } + // Fallback to the DatabaseStorage. + return self::getDatabaseStorage(); + } + + /** * Returns a Database configuration storage implementation. * * @return \Drupal\Core\Config\DatabaseStorage diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 0482bc6..8812cab 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -7,9 +7,10 @@ namespace Drupal\Core; -use Drupal\Component\Utility\Settings; use Drupal\Core\PhpStorage\PhpStorageFactory; +use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\Config\NullStorage; +use Drupal\Core\CoreServiceProvider; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderInterface; use Drupal\Core\DependencyInjection\YamlFileLoader; @@ -648,17 +649,13 @@ protected function storage() { */ protected function getConfigStorage() { if (!isset($this->configStorage)) { - $this->configStorage = new NullStorage(); // The active configuration storage may not exist yet; e.g., in the early // installer. Catch the exception thrown by config_get_config_directory(). try { - $bootstrap_config_storage = Settings::get('bootstrap_config_storage'); - if (is_callable($bootstrap_config_storage)) { - $this->configStorage = call_user_func($bootstrap_config_storage); - } + $this->configStorage = BootstrapConfigStorageFactory::get(); } catch (\Exception $e) { - // Use the NullStorage. + $this->configStorage = new NullStorage(); } } return $this->configStorage; diff --git a/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php b/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php index 3334389..95eb700 100644 --- a/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php +++ b/core/modules/language/lib/Drupal/language/LanguageServiceProvider.php @@ -7,7 +7,7 @@ namespace Drupal\language; -use Drupal\Component\Utility\Settings; +use Drupal\Core\Config\BootstrapConfigStorageFactory; use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; use Drupal\Core\Language\Language; @@ -79,15 +79,11 @@ protected function isMultilingual() { // @todo Try to swap out for config.storage to take advantage of database // and caching. This might prove difficult as this is called before the // container has finished building. - $bootstrap_config_storage = Settings::get('bootstrap_config_storage'); - if (is_callable($bootstrap_config_storage)) { - $config_storage = call_user_func($bootstrap_config_storage); - $config_ids = array_filter($config_storage->listAll($prefix), function($config_id) use ($prefix) { - return $config_id != $prefix . Language::LANGCODE_NOT_SPECIFIED && $config_id != $prefix . Language::LANGCODE_NOT_APPLICABLE; - }); - return count($config_ids) > 1; - } - return FALSE; + $config_storage = BootstrapConfigStorageFactory::get(); + $config_ids = array_filter($config_storage->listAll($prefix), function($config_id) use ($prefix) { + return $config_id != $prefix . Language::LANGCODE_NOT_SPECIFIED && $config_id != $prefix . Language::LANGCODE_NOT_APPLICABLE; + }); + return count($config_ids) > 1; } /** @@ -99,14 +95,11 @@ protected function isMultilingual() { * otherwise FALSE. */ protected function getDefaultLanguageValues() { - $bootstrap_config_storage = Settings::get('bootstrap_config_storage'); - if (is_callable($bootstrap_config_storage)) { - $config_storage = call_user_func($bootstrap_config_storage); - $system = $config_storage->read('system.site'); - $default_language = $config_storage->read(static::CONFIG_PREFIX . $system['langcode']); - if (is_array($default_language)) { - return $default_language + array('default' => TRUE); - } + $config_storage = BootstrapConfigStorageFactory::get(); + $system = $config_storage->read('system.site'); + $default_language = $config_storage->read(static::CONFIG_PREFIX . $system['langcode']); + if (is_array($default_language)) { + return $default_language + array('default' => TRUE); } return FALSE; }