diff --git a/core/lib/Drupal/Core/Config/MultiStorage.php b/core/lib/Drupal/Core/Config/MultiStorage.php new file mode 100644 index 0000000..3b0591a --- /dev/null +++ b/core/lib/Drupal/Core/Config/MultiStorage.php @@ -0,0 +1,110 @@ + $storage_options) { + $this->storages[] = new $storage_controller($storage_options); + } + $this->options = $options; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::read(). + */ + public function read($name) { + return $this->storages[0]->read($name); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::write(). + */ + public function write($name, array $data) { + $success = TRUE; + foreach ($this->storages as $storage) { + if (!$storage->write($name, $data)) { + $success = FALSE; + } + } + return $success; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::delete(). + */ + public function delete($name) { + $success = TRUE; + foreach ($this->storages as $storage) { + if (!$storage->delete($name)) { + $success = FALSE; + } + } + return $success; + } + + /** + * Implements Drupal\Core\Config\StorageInterface::encode(). + * + * @todo Remove encode() from StorageInterface. + */ + public static function encode($data) { + return $this->storages[0]->encode($data); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::decode(). + * + * @todo Remove decode() from StorageInterface. + */ + public static function decode($raw) { + return $this->storages[0]->decode($raw); + } + + /** + * Implements Drupal\Core\Config\StorageInterface::listAll(). + */ + public function listAll($prefix = '') { + return $this->storages[0]->listAll($prefix); + } +} diff --git a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index fc76eb6..75ad8d5 100644 --- a/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -49,10 +49,15 @@ class ContainerBuilder extends BaseContainerBuilder { // 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', + 'Drupal\Core\Config\DatabaseStorage' => array( + 'connection' => 'default', + 'target' => 'default', + ), + 'Drupal\Core\Config\FileStorage' => array( + 'directory' => config_get_config_directory(), + ), )); - $this->register('config.storage', 'Drupal\Core\Config\DatabaseStorage') + $this->register('config.storage', 'Drupal\Core\Config\MultiStorage') ->addArgument('%config.storage.options%'); // Register configuration object factory.