diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index 3cbbd82b7ab5a6c12b7254983b6b33a6cd4d036f..db9cf588693fb70e1271cd9d6a07cd5ac61df65f 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -437,24 +437,11 @@ function install_begin_request(&$install_state) { $container->register('settings', 'Drupal\Component\Utility\Settings') ->setFactoryClass('Drupal\Component\Utility\Settings') ->setFactoryMethod('getSingleton'); - $container->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueFactory') - ->addArgument(new Reference('service_container')) - ->addArgument(new Reference('settings')); - // Register the expirable key value store used by form cache. + $container - ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueExpirableFactory') - ->addArgument(new Reference('service_container')) - ->addArgument(new Reference('settings')); - $container->register('keyvalue.memory', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); + ->register('keyvalue', 'Drupal\Core\KeyValueStore\KeyValueMemoryFactory'); $container - ->register('keyvalue.expirable.null', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory'); - $settings = Settings::getSingleton()->getAll(); - $settings['settings_old'] = $settings; - $settings['keyvalue_expirable_default'] = 'keyvalue.expirable.null'; - // Override the default keyvalue storage to use memory as the database is - // not available. - $settings['keyvalue_default'] = 'keyvalue.memory'; - new Settings($settings); + ->register('keyvalue.expirable', 'Drupal\Core\KeyValueStore\KeyValueNullExpirableFactory'); $container->register('state', 'Drupal\Core\KeyValueStore\State') ->addArgument(new Reference('keyvalue')); @@ -1297,11 +1284,6 @@ function install_settings_form_submit($form, &$form_state) { // Add the config directories to settings.php. drupal_install_config_directories($install_state['mode']); - // The container is about to be rebuilt so we need to unset the keyvalue - // storage override that the installer is using. - $settings = Settings::getSingleton()->getAll(); - new Settings($settings['settings_old']); - // Indicate that the settings file has been verified, and check the database // for the last completed task, now that we have a valid connection. This // last step is important since we want to trigger an error if the new diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index f01f78b3c43c1784cc1a7627d97b93cd77ea9451..99a2d7381432b7025b699373290cff388031d099 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -15,6 +15,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\HttpKernel; use Drupal\Core\KeyValueStore\KeyValueExpirableFactory; +use Drupal\Core\KeyValueStore\KeyValueFactoryInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\StringTranslation\TranslationInterface; @@ -41,7 +42,7 @@ class FormBuilder implements FormBuilderInterface { /** * The factory for expirable key value stores used by form cache. * - * @var \Drupal\Core\KeyValueStore\KeyValueExpirableFactory + * @var \Drupal\Core\KeyValueStore\KeyValueFactoryInterface */ protected $keyValueExpirableFactory; @@ -123,7 +124,7 @@ class FormBuilder implements FormBuilderInterface { * * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. - * @param \Drupal\Core\KeyValueStore\KeyValueExpirableFactory $key_value_expirable_factory + * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_expirable_factory * The keyvalue expirable factory. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher * The event dispatcher. @@ -136,7 +137,7 @@ class FormBuilder implements FormBuilderInterface { * @param \Drupal\Core\HttpKernel $http_kernel * The HTTP kernel. */ - public function __construct(ModuleHandlerInterface $module_handler, KeyValueExpirableFactory $key_value_expirable_factory, EventDispatcherInterface $event_dispatcher, UrlGeneratorInterface $url_generator, TranslationInterface $translation_manager, CsrfTokenGenerator $csrf_token = NULL, HttpKernel $http_kernel = NULL) { + public function __construct(ModuleHandlerInterface $module_handler, KeyValueFactoryInterface $key_value_expirable_factory, EventDispatcherInterface $event_dispatcher, UrlGeneratorInterface $url_generator, TranslationInterface $translation_manager, CsrfTokenGenerator $csrf_token = NULL, HttpKernel $http_kernel = NULL) { $this->moduleHandler = $module_handler; $this->keyValueExpirableFactory = $key_value_expirable_factory; $this->eventDispatcher = $event_dispatcher; diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php index 0d63988af7b5120986c3f511b5e21aa7332fd59c..b70cd2bd58e9bf6ac0d14b08bc4cf111da7e6c36 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseExpirableFactory.php @@ -25,15 +25,7 @@ class KeyValueDatabaseExpirableFactory extends KeyValueDatabaseFactory implement protected $storages; /** - * Constructs a new key/value expirable database storage object for a given - * collection name. - * - * @param string $collection - * The name of the collection holding key and value pairs. - * @param \Drupal\Core\Database\Connection $connection - * The connection to run against. - * @return \Drupal\Core\KeyValueStore\DatabaseStorageExpirable - * A key/value store implementation for the given $collection. + * {@inheritdoc} */ public function get($collection) { $storage = new DatabaseStorageExpirable($collection, $this->connection); diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseFactory.php index ded528e128ec38a45030803ab2494704103391e6..1a840b39c4000aafa40c1441ed85cdd595c150f4 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueDatabaseFactory.php @@ -12,7 +12,7 @@ /** * Defines the key/value store factory for the database backend. */ -class KeyValueDatabaseFactory { +class KeyValueDatabaseFactory implements KeyValueFactoryInterface { /** * Constructs this factory object. @@ -26,14 +26,7 @@ function __construct(Connection $connection) { } /** - * Constructs a new key/value database storage object for a given collection name. - * - * @param string $collection - * The name of the collection holding key and value pairs. - * @param \Drupal\Core\Database\Connection $connection - * The connection to run against. - * @return \Drupal\Core\KeyValueStore\DatabaseStorage - * A key/value store implementation for the given $collection. + * {@inheritdoc} */ public function get($collection) { return new DatabaseStorage($collection, $this->connection); diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php index 74ccd6e5a43ebbf10e756716dafd6c9b9bb6e544..a1a9d659e843d666068643c45ea89a8d869c8696 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactory.php @@ -12,7 +12,7 @@ /** * Defines the key/value store factory. */ -class KeyValueFactory { +class KeyValueFactory implements KeyValueFactoryInterface { /** * The specific setting name prefix. @@ -68,13 +68,7 @@ function __construct(ContainerInterface $container, Settings $settings) { } /** - * Constructs a new key/value store for a given collection name. - * - * @param string $collection - * The name of the collection holding key and value pairs. - * - * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface - * A key/value store implementation for the given $collection. + * {@inheritdoc} */ public function get($collection) { if (!isset($this->stores[$collection])) { diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueFactoryInterface.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactoryInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..a2fbc9480ed715e2b1d2772e059b5fa680051b64 --- /dev/null +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueFactoryInterface.php @@ -0,0 +1,27 @@ +<?php + +/** + * @file + * Contains \Drupal\Core\KeyValueStore\KeyValueFactoryInterface. + */ + +namespace Drupal\Core\KeyValueStore; + +/** + * Defines the key/value store factory interface. + */ +interface KeyValueFactoryInterface { + + /** + * Constructs a new key/value store for a given collection name. + * + * @param string $collection + * The name of the collection holding key and value pairs. + * + * @return \Drupal\Core\KeyValueStore\KeyValueStoreInterface + * A key/value store implementation for the given $collection. + */ + public function get($collection); + +} + diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php index 95c21bedb6f5be53b52577bc9fe98a63591de54d..e2942c2ae6021ea79a898c1e4e7afa3d5d24b71b 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueMemoryFactory.php @@ -10,7 +10,7 @@ /** * Defines the key/value store factory for the database backend. */ -class KeyValueMemoryFactory { +class KeyValueMemoryFactory implements KeyValueFactoryInterface { /** * An array of keyvalue collections that are stored in memory. @@ -20,12 +20,7 @@ class KeyValueMemoryFactory { protected $collections = array(); /** - * Constructs a new key/value memory storage object for a given collection name. - * - * @param string $collection - * The name of the collection holding key and value pairs. - * @return \Drupal\Core\KeyValueStore\MemoryStorage - * A key/value store implementation for the given $collection. + * {@inheritdoc} */ public function get($collection) { if (!isset($this->collections[$collection])) { diff --git a/core/lib/Drupal/Core/KeyValueStore/KeyValueNullExpirableFactory.php b/core/lib/Drupal/Core/KeyValueStore/KeyValueNullExpirableFactory.php index 27310dab5edc20e9a4d1f6e1ae970abc820db381..008dd45054c9f15262e215ba11a0810aa0942d8a 100644 --- a/core/lib/Drupal/Core/KeyValueStore/KeyValueNullExpirableFactory.php +++ b/core/lib/Drupal/Core/KeyValueStore/KeyValueNullExpirableFactory.php @@ -10,17 +10,10 @@ /** * Defines the key/value store factory for the null backend. */ -class KeyValueNullExpirableFactory { +class KeyValueNullExpirableFactory implements KeyValueFactoryInterface { /** - * Constructs a new key/value expirable null storage object for a given - * collection name. - * - * @param string $collection - * The name of the collection holding key and value pairs. - * - * @return \Drupal\Core\KeyValueStore\DatabaseStorageExpirable - * A key/value store implementation for the given $collection. + * {@inheritdoc} */ public function get($collection) { return new NullStorageExpirable($collection); diff --git a/core/lib/Drupal/Core/KeyValueStore/State.php b/core/lib/Drupal/Core/KeyValueStore/State.php index 9a7d7aaad2adf204c5176c91d707ccd05cfe4c3f..f143d67288dd7a9a124608f4c2df75cc44007de4 100644 --- a/core/lib/Drupal/Core/KeyValueStore/State.php +++ b/core/lib/Drupal/Core/KeyValueStore/State.php @@ -29,10 +29,10 @@ class State implements StateInterface { /** * Constructs a State object. * - * @param \Drupal\Core\KeyValueStore\KeyValueFactory $key_value_factory - * The key value store to use. + * @param \Drupal\Core\KeyValueStore\KeyValueFactoryInterface $key_value_factory + * The key value store to use. */ - function __construct(KeyValueFactory $key_value_factory) { + function __construct(KeyValueFactoryInterface $key_value_factory) { $this->keyValueStore = $key_value_factory->get('state'); }