diff -u b/core/includes/config.inc b/core/includes/config.inc --- b/core/includes/config.inc +++ b/core/includes/config.inc @@ -1,7 +1,6 @@ $config_dir)); - $target_storage = new DatabaseStorage(); + $target_storage = drupal_container()->get('config.storage'); $null_storage = new NullStorage(); // Upon installation, only new config objects need to be created. @@ -47,8 +46,7 @@ * @todo Modules need a way to access the active store, whatever it is. */ function config_get_storage_names_with_prefix($prefix = '') { - $storage = new DatabaseStorage(); - return $storage->listAll($prefix); + return drupal_container()->get('config.storage')->listAll($prefix); } /** @@ -131,17 +129,16 @@ } /** - * Imports configuration from FileStorage to DatabaseStorage. + * Imports configuration from FileStorage to the active store. * * @return bool|null * TRUE if configuration was imported successfully, FALSE in case of a * synchronization error, or NULL if there are no changes to synchronize. */ function config_import() { - // Retrieve a list of differences between FileStorage and DatabaseStorage. - // @todo Leverage DI + config.storage.info. + // Retrieve a list of differences between FileStorage and the active store. $source_storage = new FileStorage(); - $target_storage = new DatabaseStorage(); + $target_storage = drupal_container()->get('config.storage'); $config_changes = config_sync_get_changes($source_storage, $target_storage); if (empty($config_changes)) { @@ -185,8 +182,6 @@ * @todo Add support for other extension types; e.g., themes etc. */ function config_import_invoke_owner(array $config_changes, StorageInterface $source_storage, StorageInterface $target_storage) { - $storage = drupal_container()->get('config.storage'); - // Allow modules to take over configuration change operations for // higher-level configuration data. // First pass deleted, then new, and lastly changed configuration, in order to @@ -199,13 +194,13 @@ // handle the configuration change. $handled_by_module = FALSE; if (module_hook($module, 'config_import_' . $op)) { - $old_config = new Config($storage); + $old_config = new Config($target_storage); $old_config ->setName($name) ->load(); $data = $source_storage->read($name); - $new_config = new Config($storage); + $new_config = new Config($target_storage); $new_config->setName($name); if ($data !== FALSE) { $new_config->setData($data); @@ -222,12 +217,11 @@ } /** - * Exports configuration from DatabaseStorage to FileStorage. + * Exports configuration from the active store to FileStorage. */ function config_export() { - // Retrieve a list of differences between DatabaseStorage and FileStorage. - // @todo Leverage DI + config.storage.info. - $source_storage = new DatabaseStorage(); + // Retrieve a list of differences between the active store and FileStorage. + $source_storage = drupal_container()->get('config.storage'); $target_storage = new FileStorage(); $config_changes = config_sync_get_changes($source_storage, $target_storage); diff -u b/core/lib/Drupal/Core/Config/ConfigFactory.php b/core/lib/Drupal/Core/Config/ConfigFactory.php --- b/core/lib/Drupal/Core/Config/ConfigFactory.php +++ b/core/lib/Drupal/Core/Config/ConfigFactory.php @@ -21,8 +21,9 @@ * @see Drupal\Core\Config\StorageInterface */ class ConfigFactory { + /** - * A storage controller instance to use for reading and writing configuration data. + * A storage controller instance for reading and writing configuration data. * * @var Drupal\Core\Config\StorageInterface */ @@ -72,2 +73,3 @@ } + } reverted: --- b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -43,21 +43,26 @@ // Register the default language content. $this->register(LANGUAGE_TYPE_CONTENT, 'Drupal\\Core\\Language\\Language'); + // Register configuration storage dispatcher. + $this->setParameter('config.storage.info', array( + 'Drupal\Core\Config\DatabaseStorage' => array( + 'connection' => 'default', + 'target' => 'default', + 'read' => TRUE, + 'write' => TRUE, + ), + 'Drupal\Core\Config\FileStorage' => array( + 'directory' => config_get_config_directory(), + 'read' => TRUE, + 'write' => FALSE, + ), - // Register configuration storage class and options. - // @todo The active store and its options need to be configurable. - // Use either global $conf (recursion warning) or global $config, or a - // bootstrap configuration *file* to allow to set/override this very - // lowest of low level configuration. - $this->setParameter('config.storage.options', array( - 'connection' => 'default', - 'target' => 'default', )); + $this->register('config.storage.dispatcher', 'Drupal\Core\Config\StorageDispatcher') + ->addArgument('%config.storage.info%'); - $this->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') - ->addArgument('%config.storage.options%'); // Register configuration object factory. $this->register('config.factory', 'Drupal\Core\Config\ConfigFactory') + ->addArgument(new Reference('config.storage.dispatcher')); - ->addArgument(new Reference('config.storage')); // Register the HTTP kernel services. $this->register('dispatcher', 'Symfony\Component\EventDispatcher\EventDispatcher') only in patch2: unchanged: --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2437,26 +2437,22 @@ function drupal_container(Container $reset = NULL) { // This will get merged with the full Kernel-built Container on normal page // requests. $container = new ContainerBuilder(); - // Register configuration storage dispatcher. - $container->setParameter('config.storage.info', array( - 'Drupal\Core\Config\DatabaseStorage' => array( - 'connection' => 'default', - 'target' => 'default', - 'read' => TRUE, - 'write' => TRUE, - ), - 'Drupal\Core\Config\FileStorage' => array( - 'directory' => config_get_config_directory(), - 'read' => TRUE, - 'write' => FALSE, - ), + + // Register configuration storage class and options. + // @todo The active store and its options need to be configurable. + // Use either global $conf (recursion warning) or global $config, or a + // bootstrap configuration *file* to allow to set/override this very + // lowest of low level configuration. + $container->setParameter('config.storage.options', array( + 'connection' => 'default', + 'target' => 'default', )); - $container->register('config.storage.dispatcher', 'Drupal\Core\Config\StorageDispatcher') - ->addArgument('%config.storage.info%'); + $container->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') + ->addArgument('%config.storage.options%'); // Register configuration object factory. $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') - ->addArgument(new Reference('config.storage.dispatcher')); + ->addArgument(new Reference('config.storage')); } return $container; }