diff --git a/core/includes/bootstrap.inc b/core/includes/bootstrap.inc index 2c9b82e..23eed11 100644 --- a/core/includes/bootstrap.inc +++ b/core/includes/bootstrap.inc @@ -2444,14 +2444,11 @@ function drupal_container(Container $reset = NULL) { // bootstrap configuration *file* to allow to set/override this very // lowest of low level configuration. $container->setParameter('config.storage.options', array( -// 'Drupal\Core\Config\DatabaseStorage' => array( -// 'connection' => 'default', -// 'target' => 'default', -// ), 'Drupal\Core\Config\FileStorage' => array( 'directory' => config_get_config_directory(), ), 'Drupal\Core\Config\CacheStorage' => array( + 'backend' => 'Drupal\Core\Cache\DatabaseBackend', // @todo Add and replace with 'config' default bin. 'bin' => 'cache', ), @@ -2464,6 +2461,15 @@ function drupal_container(Container $reset = NULL) { // Register configuration object factory. $container->register('config.factory', 'Drupal\Core\Config\ConfigFactory') ->addArgument(new Reference('config.storage')); + + // Register configuration state. + $container->setParameter('config.state.options', array( + 'connection' => 'default', + 'target' => 'default', + 'table' => 'config', + )); + $container->register('config.state', 'Drupal\Core\Config\DatabaseStorage') + ->addArgument('%config.state.options%'); } return $container; } diff --git a/core/includes/config.inc b/core/includes/config.inc index f2fcd39..14f41f9 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -17,9 +17,6 @@ * The extension type; e.g., 'module' or 'theme'. * @param string $name * The name of the module or theme to install default configuration for. - * - * @todo Make this acknowledge other storage engines rather than having - * SQL be hardcoded. */ function config_install_default_config($type, $name) { $config_dir = drupal_get_path($type, $name) . '/config'; @@ -43,7 +40,9 @@ function config_install_default_config($type, $name) { } /** - * @todo Modules need a way to access the active store, whatever it is. + * Gets configuration object names starting with a given prefix. + * + * @see Drupal\Core\Config\StorageInterface::listAll() */ function config_get_storage_names_with_prefix($prefix = '') { return drupal_container()->get('config.storage')->listAll($prefix); @@ -129,15 +128,15 @@ function config_sync_changes(array $config_changes, StorageInterface $source_sto } /** - * Imports configuration from FileStorage to the active store. + * Imports configuration into 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 the active store. - $source_storage = new FileStorage(); + // Retrieve a list of differences between last known state and active store. + $source_storage = drupal_container()->get('config.state'); $target_storage = drupal_container()->get('config.storage'); $config_changes = config_sync_get_changes($source_storage, $target_storage); @@ -217,12 +216,14 @@ function config_import_invoke_owner(array $config_changes, StorageInterface $sou } /** - * Exports configuration from the active store to FileStorage. + * Updates the last known state with the active store configuration. + * + * @todo config_export() is a misnomer now. Rename to config_state_update(). */ function config_export() { - // Retrieve a list of differences between the active store and FileStorage. + // Retrieve a list of differences between active store and last known state. $source_storage = drupal_container()->get('config.storage'); - $target_storage = new FileStorage(); + $target_storage = drupal_container()->get('config.state'); $config_changes = config_sync_get_changes($source_storage, $target_storage); if (empty($config_changes)) { diff --git a/core/modules/config/config.admin.inc b/core/modules/config/config.admin.inc index 30cc090..eefa104 100644 --- a/core/modules/config/config.admin.inc +++ b/core/modules/config/config.admin.inc @@ -5,7 +5,6 @@ * Admin page callbacks for the config module. */ -use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\StorageInterface; /** @@ -52,10 +51,11 @@ function config_admin_sync_form(array &$form, array &$form_state, StorageInterfa * Form constructor for configuration import form. * * @see config_admin_import_form_submit() + * @see config_import() */ function config_admin_import_form($form, &$form_state) { - // Retrieve a list of differences between FileStorage and the active store. - $source_storage = new FileStorage(); + // Retrieve a list of differences between last known state and active store. + $source_storage = drupal_container()->get('config.state'); $target_storage = drupal_container()->get('config.storage'); // Prevent users from deleting all configuration. @@ -103,11 +103,14 @@ function config_admin_import_form_submit($form, &$form_state) { * Form constructor for configuration export form. * * @see config_admin_export_form_submit() + * @see config_export() + * + * @todo "export" is a misnomer with config.state. */ function config_admin_export_form($form, &$form_state) { - // Retrieve a list of differences between the active store and FileStorage. + // Retrieve a list of differences between active store and last known state. $source_storage = drupal_container()->get('config.storage'); - $target_storage = new FileStorage(); + $target_storage = drupal_container()->get('config.state'); config_admin_sync_form($form, $form_state, $source_storage, $target_storage);